class TerraformLandscape::ArgumentsParser
Handles option parsing for the command line application.
def add_info_options(parser)
def add_info_options(parser) parser.on('--[no-]color', 'Force output to be colorized') do |color| @options[:color] = color end parser.on('-d', '--debug', 'Enable debug mode for more verbose output') do @options[:debug] = true end parser.on_tail('-h', '--help', 'Display help documentation') do @options[:command] = :display_help @options[:help_message] = parser.help end parser.on_tail('-v', '--version', 'Display version') do @options[:command] = :display_version end parser.on_tail('-V', '--verbose-version', 'Display verbose version information') do @options[:command] = :display_version @options[:verbose_version] = true end end
def parse(args)
-
(Hash)
- parsed options
Parameters:
-
args
(Array
) -- arguments passed via the command line
def parse(args) @options = {} @options[:command] = :pretty_print # Default command OptionParser.new do |parser| parser.banner = 'Usage: landscape [options] [plan-output-file]' add_info_options parser end.parse!(args) # Any remaining arguments are assumed to be the output file @options[:plan_output_file] = args.first @options rescue OptionParser::InvalidOption => ex raise InvalidCliOptionError, "#{ex.message}\nRun `landscape --help` to " \ 'see a list of available options.' end