Class: Trooper::CLI
- Inherits:
-
Object
- Object
- Trooper::CLI
- Defined in:
- lib/trooper/cli.rb
Instance Attribute Summary collapse
-
#argv ⇒ Object
readonly
Returns the value of attribute argv.
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#config ⇒ Object
Returns the value of attribute config.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(argv) ⇒ CLI
constructor
A new instance of CLI.
Constructor Details
#initialize(argv) ⇒ CLI
Returns a new instance of CLI.
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/trooper/cli.rb', line 16 def initialize(argv) @argv = argv @options = { :environment => :production } @command = option_parser.parse!(@argv)[0] if @command @command = @command.to_sym else raise CliArgumentError, "You didnt pass an action" end end |
Instance Attribute Details
#argv ⇒ Object (readonly)
Returns the value of attribute argv.
13 14 15 |
# File 'lib/trooper/cli.rb', line 13 def argv @argv end |
#command ⇒ Object (readonly)
Returns the value of attribute command.
13 14 15 |
# File 'lib/trooper/cli.rb', line 13 def command @command end |
#config ⇒ Object
Returns the value of attribute config.
14 15 16 |
# File 'lib/trooper/cli.rb', line 14 def config @config end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
13 14 15 |
# File 'lib/trooper/cli.rb', line 13 def @options end |
Class Method Details
.start(argv = ARGV) ⇒ Object
7 8 9 10 11 |
# File 'lib/trooper/cli.rb', line 7 def self.start(argv = ARGV) cli = self.new(argv) cli.execute cli end |
Instance Method Details
#execute ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/trooper/cli.rb', line 29 def execute case command when :init Configuration.init else config = Configuration.new() config.runner(command).execute end end |