Class: CDQ::CommandLine
- Inherits:
-
Object
- Object
- CDQ::CommandLine
- Defined in:
- lib/cdq/cli.rb
Direct Known Subclasses
Constant Summary collapse
- HELP_TEXT =
%{Usage: cdq [options] <command> [arguments] Commands: cdq init # Add boilerplate setup to use CDQ cdq create model <model> # Create a model and associated files Options: }
Instance Attribute Summary collapse
-
#singleton_options_passed ⇒ Object
readonly
Returns the value of attribute singleton_options_passed.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#singleton_options_passed ⇒ Object (readonly)
Returns the value of attribute singleton_options_passed.
17 18 19 |
# File 'lib/cdq/cli.rb', line 17 def @singleton_options_passed end |
Class Method Details
.run_all ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/cdq/cli.rb', line 35 def self.run_all actions = { "init" => InitAction, "create" => CreateAction } cli = self.new opts = cli.option_parser opts.order! action = ARGV.shift if actions[action] actions[action].new.run elsif !cli. puts opts end end |
Instance Method Details
#option_parser(help_text = HELP_TEXT) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/cdq/cli.rb', line 19 def option_parser(help_text = HELP_TEXT) OptionParser.new do |opts| opts. = help_text opts.on("-v", "--version", "Print Version") do @singleton_options_passed = true puts CDQ::VERSION end opts.on("-h", "--help", "Show this message") do @singleton_options_passed = true puts opts end end end |