Class: Waves::CLI::App

Inherits:
Object
  • Object
show all
Defined in:
lib/waves/cli/app.rb

Constant Summary collapse

COMMANDS =
%w[login account list search show transcript].freeze

Instance Method Summary collapse

Constructor Details

#initialize(argv:, stdin:, stdout:, stderr:, env:, config:, client_class:) ⇒ App

Returns a new instance of App.



13
14
15
16
17
18
19
20
21
22
# File 'lib/waves/cli/app.rb', line 13

def initialize(argv:, stdin:, stdout:, stderr:, env:, config:, client_class:)
  @argv = argv.dup
  @stdin = stdin
  @stdout = stdout
  @stderr = stderr
  @env = env
  @config = config
  @client_class = client_class
  @formatter = Formatter.new(stdout: stdout)
end

Instance Method Details

#start ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/waves/cli/app.rb', line 24

def start
  options, args = parse_global_options(@argv)
  command = args.shift

  return print_help if command.nil?
  return print_help(args.first) if command == "help"
  return print_help(command) if options[:help]

  dispatch(command, args, options)
rescue OptionParser::ParseError, CommandError, Waves::Error => error
  print_error(error, json: options&.fetch(:json, false) || false)
end