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
|
# File 'lib/morpheus/cli/cli_command.rb', line 22
def self.genericOptions(opts,options)
opts.on( '-O', '--option OPTION', "Option" ) do |option|
custom_option_args = option.split('=')
custom_options = options[:options] || {}
option_name_args = custom_option_args[0].split('.')
if option_name_args.count > 1
nested_options = custom_options
option_name_args.each_with_index do |name_element,index|
if index < option_name_args.count - 1
nested_options[name_element] = nested_options[name_element] || {}
nested_options = nested_options[name_element]
else
nested_options[name_element] = custom_option_args[1]
end
end
else
custom_options[custom_option_args[0]] = custom_option_args[1]
end
options[:options] = custom_options
end
opts.on('-C','--nocolor', "ANSI") do
Term::ANSIColor::coloring = false
end
opts.on( '-h', '--help', "Prints this help" ) do
puts opts
exit
end
opts.on('-j','--json', "JSON Output") do |json|
options[:json] = true
end
opts.on( '-y', '--yes', "Auto Confirm" ) do
options[:yes] = true
end
opts.on( '-m', '--max MAX', "Max Results" ) do |max|
options[:max] = max.to_i
end
opts.on( '-o', '--offset OFFSET', "Offset Results" ) do |offset|
options[:offset] = offset.to_i
end
opts.on( '-r', '--remote REMOTE', "Remote Appliance" ) do |remote|
options[:remote] = remote
end
opts.on( '-U', '--url REMOTE', "API Url" ) do |remote|
options[:remote_url] = remote
end
opts.on( '-u', '--username USERNAME', "Username" ) do |remote|
options[:remote_username] = remote
end
opts.on( '-p', '--password PASSWORD', "Password" ) do |remote|
options[:remote_password] = remote
end
opts.on( '-T', '--token ACCESS_TOKEN', "Access Token" ) do |remote|
options[:remote_token] = remote
end
opts.on( '-s', '--search PHRASE', "Search Phrase" ) do |phrase|
options[:phrase] = phrase
end
opts.on( '', '--sort ORDER', "Sort Order" ) do |v|
options[:sort] = v
end
opts.on( '', '--desc', "Reverse Sort Order" ) do |v|
options[:direction] = "desc"
end
end
|