Class: Flipper::CLI::Command

Inherits:
OptionParser
  • Object
show all
Defined in:
lib/flipper/cli.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(program_name: nil) ⇒ Command

Returns a new instance of Command.



246
247
248
249
250
251
# File 'lib/flipper/cli.rb', line 246

def initialize(program_name: nil)
  super()
  @program_name = program_name
  @load_environment = true
  @action = lambda { }
end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



244
245
246
# File 'lib/flipper/cli.rb', line 244

def description
  @description
end

#load_environmentObject

Returns the value of attribute load_environment.



244
245
246
# File 'lib/flipper/cli.rb', line 244

def load_environment
  @load_environment
end

Instance Method Details

#action(&block) ⇒ Object



258
259
260
# File 'lib/flipper/cli.rb', line 258

def action(&block)
  @action = block
end

#run(argv) ⇒ Object



253
254
255
256
# File 'lib/flipper/cli.rb', line 253

def run(argv)
  # Parse argv and call action with arguments
  @action.call(*permute(argv))
end