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 name', { type: :string, short: :Q }], 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 }], map: ['Mapped field name to return or update', { type: :string }], data: ['JSON string input', { type: :string }], config: ['Path to the JSON config file to use', { type: :string, short: :C }], raw: ['Return raw JSON output, rather than simplified data', { short: :R }], include_ids: ['Include ID properties in returned data'], quiet: ['Suppress logging to STDERR'], log: ['Redirect logging to STDOUT'], 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] ].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.
83 84 85 86 87 88 89 90 91 92 |
# File 'lib/usps/imis/command_line/options_parser.rb', line 83 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.
36 37 38 |
# File 'lib/usps/imis/command_line/options_parser.rb', line 36 def arguments @arguments end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
36 37 38 |
# File 'lib/usps/imis/command_line/options_parser.rb', line 36 def @options end |
Class Method Details
.banner_contents ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 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 |
# File 'lib/usps/imis/command_line/options_parser.rb', line 38 def self. <<~BANNER #{'Usage'.underline} #{'imis.rb'.bold} #{'[options]'.gray} #{'HTTP Verbs'.underline} The default HTTP verb is #{'GET'.cyan}. If #{'--data'.green}/#{'-d'.green} is provided, the default HTTP verb is #{'PUT'.cyan}. #{'--data'.green}/#{'-d'.green} is used to provide field(s) data for #{'PUT'.cyan} requests and mapper updates, object data for #{'POST'.cyan}, and to provide any query params. #{'Configuration'.underline} API configuration can be specified in two ways: With #{'--config'.green}/#{'-C'.green} given the path to a JSON file, e.g.: { "imis_id_query_name": "#{'$/IQA_QUERY_NAME'.yellow}", "environment": "#{'development'.yellow}", "username": "#{'USERNAME'.yellow}", "password": "#{'PASSWORD'.yellow}" } By setting the following environment variables: #{'IMIS_ID_QUERY_NAME'.yellow} #{'IMIS_ENVIRONMENT'.yellow} #{'IMIS_USERNAME'.yellow} #{'IMIS_PASSWORD'.yellow} #{'Options'.underline} BANNER end |