Class: CommandOptionsParser
- Defined in:
- lib/maws/command_options_parser.rb
Instance Method Summary collapse
-
#initialize(config) ⇒ CommandOptionsParser
constructor
A new instance of CommandOptionsParser.
- #process_command_options(command) ⇒ Object
- #usage(profile = nil, command = nil) ⇒ Object
Constructor Details
#initialize(config) ⇒ CommandOptionsParser
Returns a new instance of CommandOptionsParser.
4 5 6 |
# File 'lib/maws/command_options_parser.rb', line 4 def initialize(config) @config = config end |
Instance Method Details
#process_command_options(command) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/maws/command_options_parser.rb', line 8 def (command) = usage(@config.profile.name, @config.command_name) << "\n#{command.description}\n\n" << "options:\n" command_opts = Trollop:: do command.(self) command.(self) end @config.command_line.merge!(command_opts) end |
#usage(profile = nil, command = nil) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/maws/command_options_parser.rb', line 21 def usage(profile = nil, command = nil) profile ||= 'profile' command ||= 'command' <<-EOS MAWS - Toolset for provisioning and managing AWS Usage: maws.rb #{profile} #{command} [options] profiles: #{@config.config.available_profiles.keys.join(', ')} commands: #{@config.config.available_commands.keys.join(', ')} EOS end |