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 =
{ certificate: ['Member certificate number', { type: :string }], id: ['Member iMIS ID', { type: :integer }], on: ['Business Object name', { type: :string }], panel: ['Panel name', { type: :string }], ordinal: ['Ordinal ID within a Panel', { type: :integer }], 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 }], create: ["Send a #{'POST'.cyan} request", { short: :P }], delete: ["Send a #{'DELETE'.cyan} request", { short: :D }], 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 }], 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 map], %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
- DEPENDENT_OPTION_PAIRS =
[ %i[ordinal panel], %i[create data] ].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.
89 90 91 92 93 94 95 96 97 98 |
# File 'lib/usps/imis/command_line/options_parser.rb', line 89 def initialize @options = .compact @arguments = ARGV # Not currently used # :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.
61 62 63 |
# File 'lib/usps/imis/command_line/options_parser.rb', line 61 def arguments @arguments end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
61 62 63 |
# File 'lib/usps/imis/command_line/options_parser.rb', line 61 def @options end |
Class Method Details
.banner_contents ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/usps/imis/command_line/options_parser.rb', line 70 def self. <<~BANNER #{'Usage'.underline} #{'imis.rb'.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
63 64 65 66 67 68 |
# File 'lib/usps/imis/command_line/options_parser.rb', line 63 def self.(version) <<~BANNER #{version.bold.blue} #{'P/R/C Julian Fiander, SN'.gray}\n \n BANNER end |