Class: Bane::CommandLineConfiguration

Inherits:
Object
  • Object
show all
Defined in:
lib/bane/command_line_configuration.rb

Instance Method Summary collapse

Constructor Details

#initialize(makeables) ⇒ CommandLineConfiguration

Returns a new instance of CommandLineConfiguration.



10
11
12
13
# File 'lib/bane/command_line_configuration.rb', line 10

def initialize(makeables)
  @behavior_maker = BehaviorMaker.new(makeables)
  @arguments_parser = ArgumentsParser.new(makeables.keys)
end

Instance Method Details

#process(args, &error_policy) ⇒ Object



15
16
17
18
19
20
# File 'lib/bane/command_line_configuration.rb', line 15

def process(args, &error_policy)
  arguments = @arguments_parser.parse(args)
  create(arguments.behaviors, arguments.port, arguments.host)
rescue ConfigurationError => ce
  error_policy.call([ce.message, @arguments_parser.usage].join("\n"))
end