7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
# File 'lib/cem_acpt/cli.rb', line 7
def self.parse_opts_for(command)
cmd = command
options = {}
parser = OptionParser.new do |opts|
opts.banner = "Usage: #{command} [options]"
opts.on('-h', '--help', 'Show this help message') do
puts opts
exit 0
end
case command
when :cem_acpt
opts.on('-m', '--module-dir DIR', 'Set module directory. Example: -m "/tmp/module"') do |m|
options[:module_dir] = m
end
opts.on('-a', '--only-actions ACTIONS', 'Set actions. Example: -a "acpt,noop"') do |a|
options[:actions] ||= {}
options[:actions][:only] = a.split(',')
end
opts.on('-A', '--except-actions ACTIONS', 'Set excluded actions. Example: -A "noop,idempotent"') do |a|
options[:actions] ||= {}
options[:actions][:except] = a.split(',')
end
opts.on('-t', '--tests TESTS', 'Set tests. Example: -t "test1,test2"') do |t|
options[:tests] = t.split(',')
end
when :cem_acpt_image
opts.on('-U', '--no-linux', 'Do not build Linux images') do
options[:cem_acpt_image] ||= {}
options[:cem_acpt_image][:no_linux] = true
end
opts.on('-W', '--no-windows', 'Do not build Windows images') do
options[:cem_acpt_image] ||= {}
options[:cem_acpt_image][:no_windows] = true
end
end
opts.on('-D', '--debug', 'Enable debug logging') do
options[:log_level] = 'debug'
end
opts.on('-L', '--log-file FILE', 'Log to FILE') do |file|
options[:log_file] = file
end
opts.on('-O', '--options OPTS', 'Set options. Example: -P "param1=value1,param2=value2"') do |o|
params = o.split(',').map { |s| s.split('=') }.to_h
params.transform_keys(&:to_sym).each do |k, v|
options[k] = v
end
end
opts.on('-p', '--platform PLATFORM', 'Set platform. Example: -p "gcp"') do |p|
options[:platform] = p
end
opts.on('-c', '--config-file FILE', 'Set config file. Example: -c "/tmp/config.yaml"') do |c|
options[:config_file] = c
end
opts.on('-I', '--CI', 'Run in CI mode (modifies logging for Github Actions output)') do
options[:ci_mode] = true
options[:log_format] = 'github_action'
end
opts.on('-E', '--no-destroy-nodes', 'Do not destroy nodes') do
options[:no_destroy_nodes] = true
end
opts.on('-q', '--quiet', 'Do not log to stdout') do
options[:quiet] = true
end
opts.on('-v', '--verbose', 'Enables verbose logging mode') do
options[:verbose] = true
end
opts.on('-S', '--no-epehemeral-ssh-key', 'Do not generate an ephemeral SSH key for test suites') do
options[:no_ephemeral_ssh_key] = true
end
opts.on('-V', '--version', 'Show the cem_acpt version') do
cmd = :version
end
opts.on('-Y', '--print-yaml-config', 'Loads and prints the config as YAML. Other specified options will be added to the config.') do
cmd = :print_yaml_config
end
opts.on('-X', '--explain-config', 'Loads and prints the config explanation. Other specified options will be added to the config.') do
cmd = :print_explain_config
end
end
parser.parse!
[cmd, options]
end
|