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

Defined Under Namespace

Classes: Record, Serve

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

#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