Class: Supermarket::SupermarketCLI
Class Method Summary
collapse
Instance Method Summary
collapse
audit_log_options, check_license!, exec_options, exit_on_failure?, fetch_and_persist_license, format_platform_info, help, profile_options, start, supermarket_options, target_options
Class Method Details
.banner(command, _namespace = nil, _subcommand = false) ⇒ Object
9
10
11
|
# File 'lib/bundles/inspec-supermarket/cli.rb', line 9
def self.banner(command, _namespace = nil, _subcommand = false)
"#{basename} #{subcommand_prefix} #{command.usage}"
end
|
.subcommand_prefix ⇒ Object
13
14
15
|
# File 'lib/bundles/inspec-supermarket/cli.rb', line 13
def self.subcommand_prefix
namespace
end
|
Instance Method Details
#exec(*tests) ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/bundles/inspec-supermarket/cli.rb', line 38
def exec(*tests)
o = config
diagnose(o)
configure_logger(o)
tests = tests.map { |t| "supermarket://" + t }
runner = Inspec::Runner.new(o)
tests.each { |target| runner.add_target(target) }
exit runner.run
rescue ArgumentError, RuntimeError, Train::UserError => e
$stderr.puts e.message
exit 1
end
|
#info(profile) ⇒ Object
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
82
83
84
|
# File 'lib/bundles/inspec-supermarket/cli.rb', line 57
def info(profile)
o = config
diagnose(o)
configure_logger(o)
supermarket_profiles = if o["supermarket_url"]
Supermarket::API.profiles(o["supermarket_url"])
else
Supermarket::API.profiles
end
found = supermarket_profiles.select do |p|
profile == "#{p["tool_owner"]}/#{p["slug"]}"
end
if found.empty?
puts "#{mark_text(profile)} is not available on Supermarket"
return
end
info = Supermarket::API.info(profile)
puts "#{mark_text("name: ")} #{info["slug"]}"
puts "#{mark_text("owner:")} #{info["owner"]}"
puts "#{mark_text("url: ")} #{info["source_url"]}"
puts
puts "#{mark_text("description: ")} #{info["description"]}"
end
|
#profiles ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/bundles/inspec-supermarket/cli.rb', line 19
def profiles
o = config
diagnose(o)
configure_logger(o)
supermarket_profiles = if o["supermarket_url"]
Supermarket::API.profiles(o["supermarket_url"])
else
Supermarket::API.profiles
end
headline("Available profiles:")
supermarket_profiles.each do |p|
li("#{p["tool_name"]} #{mark_text(p["tool_owner"] + "/" + p["slug"])}")
end
end
|