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 }], record_id: ['Specific Record ID', { type: :integer, short: :I }], uuid: ['Record UUID', { type: :string }], # 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"], jsonl: ['Format array output as JSONL', { short: :j }], 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 uuid], i[record_id uuid], 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.
102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/usps/imis/command_line/options_parser.rb', line 102 def initialize = .compact @arguments = ARGV # Not currently used Optimist.educate if ARGV.empty? && defaults? # DEV: This shadows setting the --version flag by default # :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.
74 75 76 |
# File 'lib/usps/imis/command_line/options_parser.rb', line 74 def arguments @arguments end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
74 75 76 |
# File 'lib/usps/imis/command_line/options_parser.rb', line 74 def end |
Class Method Details
.banner_contents ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/usps/imis/command_line/options_parser.rb', line 83 def self. " \#{'Usage'.underline}\n\n \#{'imis'.bold} \#{'[options]'.gray}\n\n\n \#{'Further Help'.underline}\n\n For an explanation of how to provide API configuration, more details on the options,\n and usage examples, please refer to the wiki:\n\n https://github.com/unitedstatespowersquadrons/imis-api-ruby/wiki/Command-Line\n\n\n \#{'Options'.underline}\n BANNER\nend\n" |
.banner_header(version) ⇒ Object
76 77 78 79 80 81 |
# File 'lib/usps/imis/command_line/options_parser.rb', line 76 def self.(version) " \#{version.bold.blue}\n \#{'P/R/C Julian Fiander, SN'.gray}\\n \\n\n BANNER\nend\n" |