class TerraformLandscape::ArgumentsParser

def parse(args)

Returns:
  • (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