Class: Usps::Imis::CommandLine::Interface

Inherits:
Object
  • Object
show all
Defined in:
lib/usps/imis/command_line/interface.rb

Overview

Command line interface for the Api

Constant Summary collapse

NAME =
'USPS iMIS API - Ruby'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeInterface

Returns a new instance of Interface.



21
22
23
24
25
26
27
# File 'lib/usps/imis/command_line/interface.rb', line 21

def initialize(**)
  @options = input_options.merge(**)
  validate_options!
  configure! if options[:config]
  logging!
  @logger ||= Imis.logger('CommandLine')
end

Instance Attribute Details

#loggerObject (readonly)

Tagged logger



17
18
19
# File 'lib/usps/imis/command_line/interface.rb', line 17

def logger
  @logger
end

#optionsObject (readonly)

Options passed in from the command line



13
14
15
# File 'lib/usps/imis/command_line/interface.rb', line 13

def options
  @options
end

Class Method Details

.runObject



19
# File 'lib/usps/imis/command_line/interface.rb', line 19

def self.run(...) = new(...).run

Instance Method Details

#runObject



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/usps/imis/command_line/interface.rb', line 29

def run
  logger.info 'Running'
  logger.debug 'CLI Options:'
  logger.json options

  set_member

  result = simplify(perform!)

  output { result }

  result
end