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 accessing a single mapped field\n Equivalent to #{'-Mf'.green}", { type: :string }], post: ["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\n When present, sets the default HTTP verb to #{'PUT'.cyan}", { 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 #{'iMIS ID'.yellow} and #{'Ordinal'.yellow} properties in returned data, if present"], 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[post delete], i[post mapper], i[post query], i[post map], i[delete mapper], i[delete query], i[delete map] ].freeze
- DEPENDENT_OPTION_PAIRS =
[ i[ordinal panel] ].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.
85 86 87 88 89 90 91 92 93 94 |
# File 'lib/usps/imis/command_line/options_parser.rb', line 85 def initialize = .compact @arguments = ARGV # Not currently used # :nocov: [:data] = read_stdin if stdin? # :nocov: [:data] = JSON.parse([:data]) if [:data] end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
54 55 56 |
# File 'lib/usps/imis/command_line/options_parser.rb', line 54 def arguments @arguments end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
54 55 56 |
# File 'lib/usps/imis/command_line/options_parser.rb', line 54 def end |
Class Method Details
.banner_contents ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/usps/imis/command_line/options_parser.rb', line 56 def self. " \#{'Usage'.underline}\n\n \#{'imis.rb'.bold} \#{'[options]'.gray}\n\n\n \#{'HTTP Verbs'.underline}\n\n The default HTTP verb is \#{'GET'.cyan}.\n\n If \#{'--data'.green}/\#{'-d'.green} is provided, the default HTTP verb is \#{'PUT'.cyan}.\n\n \#{'--data'.green}/\#{'-d'.green} is used to provide field(s) data for \#{'PUT'.cyan}\n requests and mapper updates, object data for \#{'POST'.cyan},\n and to provide any query params.\n\n\n \#{'Configuration'.underline}\n\n For an explanation of how to provide API configuration, please refer to the wiki:\n\n https://github.com/unitedstatespowersquadrons/imis-api-ruby/wiki/Usage#command-line-interface\n\n\n \#{'Options'.underline}\n BANNER\nend\n" |