Class: Usps::Imis::CommandLine::OptionsParser
- Inherits:
-
Object
- Object
- Usps::Imis::CommandLine::OptionsParser
- Defined in:
- lib/usps/imis/command_line/options_parser.rb
Overview
Command line options parser
Constant Summary collapse
- OPTIONS =
{ # IDs certificate: ['Member certificate number', { type: :string }], id: ['Member iMIS ID', { type: :integer }], # Primary interactions on: ['Business Object name', { type: :string }], panel: ['Panel name', { type: :string }], query: ['IQA Query or Business Object name to query', { type: :string, short: :Q }], mapper: ['Interact with mapped fields', { short: :M }], map: ["Shorthand for #{'-Mf'.green} to access a single mapped field", { type: :string }], business_objects: ['List available Business Objects'], # Alternate verbs create: ["Send a #{'POST'.cyan} request", { short: :P }], delete: ["Send a #{'DELETE'.cyan} request", { short: :D }], # Data ordinal: ['Ordinal ID within a Panel', { type: :integer }], field: ['Specific field to return or update', { type: :string }], fields: ['Specific field(s) to return', { type: :strings, short: :F }], data: ['JSON string input', { type: :string }], # Iteractions for supporting other language wrappers auth_token: ['Return an auth token for other language wrappers', { short: :T }], token: ['Provide an existing auth token', { type: :string }], # General config config: ['Path to the JSON/YAML config file to use', { type: :string, short: :C }], raw: ['Return raw JSON output, rather than simplified data', { short: :R }], include_ids: ["Include any #{'iMIS ID'.yellow} and #{'Ordinal'.yellow} properties in returned data"], quiet: ["Suppress logging to #{'STDERR'.red}"], log: ["Redirect logging to #{'STDOUT'.red}"], log_level: ['Set the logging level', { type: :string, default: 'info', short: :L }] }.freeze
- CONFLICTING_OPTION_GROUPS =
[ %i[certificate id], %i[on panel query mapper map business_objects auth_token], %i[field fields map query], %i[raw include_ids], %i[quiet log_level], %i[quiet log], %i[create delete], %i[create mapper], %i[create query], %i[create map], %i[create field], %i[create fields], %i[delete mapper], %i[delete query], %i[delete map], %i[delete field], %i[delete fields], %i[delete data], %i[delete raw] ].freeze
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ OptionsParser
constructor
A new instance of OptionsParser.
Constructor Details
#initialize ⇒ OptionsParser
Returns a new instance of OptionsParser.
98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/usps/imis/command_line/options_parser.rb', line 98 def initialize @options = .compact @arguments = ARGV # Not currently used Optimist.educate if ARGV.empty? && defaults? # DEV: This shadows setting the --version flag by default # :nocov: @options[:data] = read_stdin if stdin? # :nocov: @options[:data] = JSON.parse(@options[:data]) if @options[:data] end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
70 71 72 |
# File 'lib/usps/imis/command_line/options_parser.rb', line 70 def arguments @arguments end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
70 71 72 |
# File 'lib/usps/imis/command_line/options_parser.rb', line 70 def @options end |
Class Method Details
.banner_contents ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/usps/imis/command_line/options_parser.rb', line 79 def self. <<~BANNER #{'Usage'.underline} #{'imis'.bold} #{'[options]'.gray} #{'Further Help'.underline} For an explanation of how to provide API configuration, more details on the options, and usage examples, please refer to the wiki: https://github.com/unitedstatespowersquadrons/imis-api-ruby/wiki/Command-Line #{'Options'.underline} BANNER end |
.banner_header(version) ⇒ Object
72 73 74 75 76 77 |
# File 'lib/usps/imis/command_line/options_parser.rb', line 72 def self.(version) <<~BANNER #{version.bold.blue} #{'P/R/C Julian Fiander, SN'.gray}\n \n BANNER end |