Class: RedfishTools::Cli

Inherits:
Thor
  • Object
show all
Defined in:
lib/redfish_tools/cli.rb,
lib/redfish_tools/cli/serve.rb,
lib/redfish_tools/cli/record.rb,
lib/redfish_tools/cli/serve_sse.rb,
lib/redfish_tools/cli/listen_sse.rb

Defined Under Namespace

Classes: ListenSse, Record, Serve, ServeSse

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/redfish_tools/cli.rb', line 14

def self.exit_on_failure?
  true
end

.start(args = ARGV) ⇒ Object



7
8
9
10
11
12
# File 'lib/redfish_tools/cli.rb', line 7

def self.start(args = ARGV)
  if HELP_MAPPINGS.any? { |flag| args.include?(flag) }
    args = ["--help", args.first]
  end
  super(args)
end

Instance Method Details

#listen_sse(address) ⇒ Object



89
90
91
92
# File 'lib/redfish_tools/cli.rb', line 89

def listen_sse(address)
  require "redfish_tools/cli/listen_sse"
  ListenSse.new(address, options).run
end

#record(service, path) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
# File 'lib/redfish_tools/cli.rb', line 59

def record(service, path)
  username = ENV["REDFISH_USERNAME"]
  password = ENV["REDFISH_PASSWORD"]
  raise "Missing username" if username.nil?
  raise "Missing password" if password.nil?

  require "redfish_tools/cli/record"
  Record.new(service, path, username, password).run
rescue StandardError => e
  raise Thor::Error, e.to_s
end

#serve(path) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/redfish_tools/cli.rb', line 34

def serve(path)
  user = options[:user]
  pass = options[:pass]
  raise "Missing password" if user && pass.nil?
  raise "Missing username" if user.nil? && pass

  require "redfish_tools/cli/serve"
  Serve.new(path, options).run
rescue StandardError => e
  raise Thor::Error, e.to_s
end

#serve_sse(source) ⇒ Object



83
84
85
86
# File 'lib/redfish_tools/cli.rb', line 83

def serve_sse(source)
  require "redfish_tools/cli/serve_sse"
  ServeSse.new(source, options).run
end