Class: TXPRails::Commands
- Inherits:
-
Object
- Object
- TXPRails::Commands
- Defined in:
- lib/txprails/commands.rb
Overview
This module handles miscelaneous command line utilities
Instance Method Summary collapse
-
#initialize(args) ⇒ Commands
constructor
A new instance of Commands.
-
#parse! ⇒ Object
Parses the command-line arguments and runs the executable.
-
#to_s ⇒ String
A description of the executable.
Constructor Details
#initialize(args) ⇒ Commands
Returns a new instance of Commands.
8 9 10 11 12 13 |
# File 'lib/txprails/commands.rb', line 8 def initialize(args) @args = args @options = {} @options[:requires] = [] # ?? @options[:load_paths] = [] # ?? end |
Instance Method Details
#parse! ⇒ Object
Parses the command-line arguments and runs the executable. Calls ‘Kernel#exit` at the end, so it never returns.
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/txprails/commands.rb', line 17 def parse! begin @opts = OptionParser.new(&method(:set_opts)) @opts.parse!(@args) @options rescue Exception => e raise e if e.is_a?(SystemExit) $stderr.puts e. exit 1 end exit 0 end |
#to_s ⇒ String
Returns A description of the executable.
32 33 34 |
# File 'lib/txprails/commands.rb', line 32 def to_s @opts.to_s end |