morpheus-cli 4.2.21 → 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Dockerfile +1 -1
- data/lib/morpheus/api/api_client.rb +30 -0
- data/lib/morpheus/api/billing_interface.rb +34 -0
- data/lib/morpheus/api/catalog_item_types_interface.rb +9 -0
- data/lib/morpheus/api/deploy_interface.rb +1 -1
- data/lib/morpheus/api/deployments_interface.rb +20 -1
- data/lib/morpheus/api/forgot_password_interface.rb +17 -0
- data/lib/morpheus/api/instances_interface.rb +16 -2
- data/lib/morpheus/api/rest_interface.rb +0 -6
- data/lib/morpheus/api/roles_interface.rb +14 -0
- data/lib/morpheus/api/search_interface.rb +13 -0
- data/lib/morpheus/api/servers_interface.rb +14 -0
- data/lib/morpheus/api/service_catalog_interface.rb +89 -0
- data/lib/morpheus/api/usage_interface.rb +18 -0
- data/lib/morpheus/cli.rb +7 -3
- data/lib/morpheus/cli/apps.rb +6 -27
- data/lib/morpheus/cli/backup_jobs_command.rb +3 -0
- data/lib/morpheus/cli/backups_command.rb +3 -0
- data/lib/morpheus/cli/catalog_item_types_command.rb +622 -0
- data/lib/morpheus/cli/cli_command.rb +70 -21
- data/lib/morpheus/cli/commands/standard/curl_command.rb +26 -12
- data/lib/morpheus/cli/commands/standard/history_command.rb +3 -1
- data/lib/morpheus/cli/commands/standard/man_command.rb +74 -40
- data/lib/morpheus/cli/commands/standard/source_command.rb +1 -1
- data/lib/morpheus/cli/commands/standard/update_command.rb +76 -0
- data/lib/morpheus/cli/containers_command.rb +14 -24
- data/lib/morpheus/cli/cypher_command.rb +6 -2
- data/lib/morpheus/cli/deploy.rb +199 -90
- data/lib/morpheus/cli/deployments.rb +341 -28
- data/lib/morpheus/cli/deploys.rb +206 -41
- data/lib/morpheus/cli/error_handler.rb +7 -0
- data/lib/morpheus/cli/forgot_password.rb +133 -0
- data/lib/morpheus/cli/groups.rb +1 -1
- data/lib/morpheus/cli/health_command.rb +59 -2
- data/lib/morpheus/cli/hosts.rb +265 -34
- data/lib/morpheus/cli/instances.rb +186 -100
- data/lib/morpheus/cli/invoices_command.rb +33 -16
- data/lib/morpheus/cli/jobs_command.rb +28 -6
- data/lib/morpheus/cli/library_option_lists_command.rb +15 -7
- data/lib/morpheus/cli/library_option_types_command.rb +5 -2
- data/lib/morpheus/cli/logs_command.rb +9 -6
- data/lib/morpheus/cli/mixins/accounts_helper.rb +12 -7
- data/lib/morpheus/cli/mixins/backups_helper.rb +2 -4
- data/lib/morpheus/cli/mixins/deployments_helper.rb +31 -3
- data/lib/morpheus/cli/mixins/option_source_helper.rb +1 -1
- data/lib/morpheus/cli/mixins/print_helper.rb +46 -21
- data/lib/morpheus/cli/mixins/provisioning_helper.rb +100 -4
- data/lib/morpheus/cli/network_pools_command.rb +14 -6
- data/lib/morpheus/cli/option_types.rb +271 -22
- data/lib/morpheus/cli/ping.rb +0 -1
- data/lib/morpheus/cli/remote.rb +35 -12
- data/lib/morpheus/cli/reports_command.rb +99 -30
- data/lib/morpheus/cli/roles.rb +453 -113
- data/lib/morpheus/cli/search_command.rb +182 -0
- data/lib/morpheus/cli/service_catalog_command.rb +1474 -0
- data/lib/morpheus/cli/service_plans_command.rb +2 -2
- data/lib/morpheus/cli/setup.rb +1 -1
- data/lib/morpheus/cli/shell.rb +33 -11
- data/lib/morpheus/cli/storage_providers_command.rb +40 -56
- data/lib/morpheus/cli/tasks.rb +29 -32
- data/lib/morpheus/cli/usage_command.rb +203 -0
- data/lib/morpheus/cli/user_settings_command.rb +1 -0
- data/lib/morpheus/cli/users.rb +12 -1
- data/lib/morpheus/cli/version.rb +1 -1
- data/lib/morpheus/cli/virtual_images.rb +429 -254
- data/lib/morpheus/cli/whoami.rb +6 -6
- data/lib/morpheus/cli/workflows.rb +34 -41
- data/lib/morpheus/formatters.rb +75 -7
- data/lib/morpheus/terminal.rb +6 -2
- metadata +14 -2
@@ -194,7 +194,7 @@ module Morpheus
|
|
194
194
|
if option_type['placeHolder']
|
195
195
|
value_label = option_type['placeHolder']
|
196
196
|
elsif option_type['type'] == 'checkbox'
|
197
|
-
value_label = 'on|off' # or.. true|false
|
197
|
+
value_label = '[on|off]' # or.. true|false
|
198
198
|
elsif option_type['type'] == 'number'
|
199
199
|
value_label = 'NUMBER'
|
200
200
|
elsif option_type['type'] == 'multiSelect'
|
@@ -203,13 +203,23 @@ module Morpheus
|
|
203
203
|
# value_label = 'SELECT'
|
204
204
|
# elsif option['type'] == 'select'
|
205
205
|
end
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
206
|
+
full_option = "--#{full_field_name} #{value_label}"
|
207
|
+
shorthand_option = option_type['shorthand']
|
208
|
+
arg1, arg2 = full_option, String
|
209
|
+
if option_type['shorthand']
|
210
|
+
arg1, arg2 = full_option, option_type['shorthand']
|
211
|
+
end
|
212
|
+
opts.on(arg1, arg2, description) do |val|
|
213
|
+
if option_type['type'] == 'checkbox'
|
214
|
+
val = (val.to_s != 'false' && val.to_s != 'off')
|
215
|
+
else
|
216
|
+
# attempt to parse JSON, this allows blank arrays for multiSelect like --tenants []
|
217
|
+
if (val.to_s[0] == '{' && val.to_s[-1] == '}') || (val.to_s[0] == '[' && val.to_s[-1] == ']')
|
218
|
+
begin
|
219
|
+
val = JSON.parse(val)
|
220
|
+
rescue
|
221
|
+
Morpheus::Logging::DarkPrinter.puts "Failed to parse option value '#{val}' as JSON" if Morpheus::Logging.debug?
|
222
|
+
end
|
213
223
|
end
|
214
224
|
end
|
215
225
|
cur_namespace = custom_options
|
@@ -265,6 +275,11 @@ module Morpheus
|
|
265
275
|
build_standard_delete_options(opts, options, includes, excludes)
|
266
276
|
end
|
267
277
|
|
278
|
+
# number of decimal places to show with curreny
|
279
|
+
def default_sigdig
|
280
|
+
2
|
281
|
+
end
|
282
|
+
|
268
283
|
# appends to the passed OptionParser all the generic options
|
269
284
|
# @param opts [OptionParser] the option parser object being constructed
|
270
285
|
# @param options [Hash] the output Hash that is to being modified
|
@@ -305,6 +320,20 @@ module Morpheus
|
|
305
320
|
opts.add_hidden_option('-a, --account') if opts.is_a?(Morpheus::Cli::OptionParser)
|
306
321
|
opts.add_hidden_option('-A, --account-id') if opts.is_a?(Morpheus::Cli::OptionParser)
|
307
322
|
|
323
|
+
when :details
|
324
|
+
opts.on('-a', '--all', "Show all details." ) do
|
325
|
+
options[:details] = true
|
326
|
+
end
|
327
|
+
opts.on('--details', '--details', "Show more details" ) do
|
328
|
+
options[:details] = true
|
329
|
+
end
|
330
|
+
opts.add_hidden_option('--details')
|
331
|
+
|
332
|
+
when :sigdig
|
333
|
+
opts.on('--sigdig DIGITS', "Significant digits to display for prices (currency). Default is #{default_sigdig}.") do |val|
|
334
|
+
options[:sigdig] = val.to_i
|
335
|
+
end
|
336
|
+
|
308
337
|
when :options
|
309
338
|
options[:options] ||= {}
|
310
339
|
opts.on( '-O', '--option OPTION', "Option in the format -O field=\"value\"" ) do |option|
|
@@ -489,13 +518,17 @@ module Morpheus
|
|
489
518
|
|
490
519
|
when :query, :query_filters
|
491
520
|
# arbitrary query parameters in the format -Q "category=web&phrase=nginx"
|
521
|
+
# or pass it many times like -Q foo=bar -Q hello=world
|
492
522
|
opts.on( '-Q', '--query PARAMS', "Query parameters. PARAMS format is 'foo=bar&category=web'" ) do |val|
|
493
|
-
options[:query_filters_raw]
|
494
|
-
|
495
|
-
|
523
|
+
if options[:query_filters_raw] && !options[:query_filters_raw].empty?
|
524
|
+
options[:query_filters_raw] += ("&" + val)
|
525
|
+
else
|
526
|
+
options[:query_filters_raw] = val
|
527
|
+
end
|
528
|
+
options[:query_filters] ||= {}
|
496
529
|
val.split('&').each do |filter|
|
497
530
|
k, v = filter.split('=')
|
498
|
-
# allow
|
531
|
+
# allow woot:true instead of woot=true
|
499
532
|
if (k.include?(":") && v == nil)
|
500
533
|
k, v = k.split(":")
|
501
534
|
end
|
@@ -594,13 +627,13 @@ module Morpheus
|
|
594
627
|
end
|
595
628
|
# opts.add_hidden_option('-H') if opts.is_a?(Morpheus::Cli::OptionParser)
|
596
629
|
# opts.add_hidden_option('--header') if opts.is_a?(Morpheus::Cli::OptionParser)
|
597
|
-
opts.add_hidden_option('--
|
630
|
+
opts.add_hidden_option('-H, --header') if opts.is_a?(Morpheus::Cli::OptionParser)
|
598
631
|
|
599
632
|
#when :timeout
|
600
633
|
opts.on( '--timeout SECONDS', "Timeout for api requests. Default is typically 30 seconds." ) do |val|
|
601
634
|
options[:timeout] = val ? val.to_f : nil
|
602
635
|
end
|
603
|
-
|
636
|
+
opts.add_hidden_option('--timeout') if opts.is_a?(Morpheus::Cli::OptionParser)
|
604
637
|
|
605
638
|
when :auto_confirm
|
606
639
|
opts.on( '-y', '--yes', "Auto Confirm" ) do
|
@@ -707,7 +740,7 @@ module Morpheus
|
|
707
740
|
|
708
741
|
|
709
742
|
when :dry_run
|
710
|
-
opts.on('-d','--dry-run', "Dry Run, print the API request instead of executing it") do
|
743
|
+
opts.on('-d','--dry-run', "Dry Run, print the API request instead of executing it.") do
|
711
744
|
# todo: this should print after parsing obv..
|
712
745
|
# need a hook after parse! or a standard_handle(options) { ... } paradigm
|
713
746
|
# either that or hook it up in every command somehow, maybe a hook on connect()
|
@@ -719,7 +752,7 @@ module Morpheus
|
|
719
752
|
end
|
720
753
|
options[:dry_run] = true
|
721
754
|
end
|
722
|
-
opts.on(nil,'--curl', "
|
755
|
+
opts.on(nil,'--curl', "Curl, print the API request as a curl command instead of executing it.") do
|
723
756
|
# print once and dont munge json
|
724
757
|
if !options[:dry_run] && !options[:json]
|
725
758
|
puts "#{cyan}#{bold}#{dark}DRY RUN#{reset}"
|
@@ -822,10 +855,18 @@ module Morpheus
|
|
822
855
|
opts
|
823
856
|
end
|
824
857
|
|
858
|
+
def prog_name
|
859
|
+
self.class.prog_name
|
860
|
+
end
|
861
|
+
|
825
862
|
def command_name
|
826
863
|
self.class.command_name
|
827
864
|
end
|
828
865
|
|
866
|
+
def command_description
|
867
|
+
self.class.command_description
|
868
|
+
end
|
869
|
+
|
829
870
|
def subcommands
|
830
871
|
self.class.subcommands
|
831
872
|
end
|
@@ -862,14 +903,14 @@ module Morpheus
|
|
862
903
|
|
863
904
|
def usage
|
864
905
|
if !subcommands.empty?
|
865
|
-
"Usage:
|
906
|
+
"Usage: #{prog_name} #{command_name} [command] [options]"
|
866
907
|
else
|
867
|
-
"Usage:
|
908
|
+
"Usage: #{prog_name} #{command_name} [options]"
|
868
909
|
end
|
869
910
|
end
|
870
911
|
|
871
912
|
def my_help_command
|
872
|
-
"
|
913
|
+
"#{prog_name} #{command_name} --help"
|
873
914
|
end
|
874
915
|
|
875
916
|
def subcommand_usage(*extra)
|
@@ -880,7 +921,7 @@ module Morpheus
|
|
880
921
|
extra.shift
|
881
922
|
end
|
882
923
|
#extra = ["[options]"] if extra.empty?
|
883
|
-
"Usage:
|
924
|
+
"Usage: #{prog_name} #{command_name} #{subcommand_name} #{extra.join(' ')}".squeeze(' ').strip
|
884
925
|
end
|
885
926
|
|
886
927
|
# a string to describe the usage of your command
|
@@ -900,6 +941,10 @@ module Morpheus
|
|
900
941
|
out << "\n"
|
901
942
|
}
|
902
943
|
end
|
944
|
+
if command_description
|
945
|
+
out << "\n"
|
946
|
+
out << "#{command_description}\n"
|
947
|
+
end
|
903
948
|
# out << "\n"
|
904
949
|
out
|
905
950
|
end
|
@@ -931,7 +976,7 @@ module Morpheus
|
|
931
976
|
end
|
932
977
|
cmd_method = subcommands[subcommand_name]
|
933
978
|
if !cmd_method
|
934
|
-
error_msg = "'#{command_name} #{subcommand_name}' is not a
|
979
|
+
error_msg = "'#{command_name} #{subcommand_name}' is not a #{prog_name} command.\n#{full_command_usage}"
|
935
980
|
raise CommandNotFoundError.new(error_msg)
|
936
981
|
end
|
937
982
|
self.send(cmd_method, args[1..-1])
|
@@ -1287,6 +1332,10 @@ module Morpheus
|
|
1287
1332
|
|
1288
1333
|
module ClassMethods
|
1289
1334
|
|
1335
|
+
def prog_name
|
1336
|
+
"morpheus"
|
1337
|
+
end
|
1338
|
+
|
1290
1339
|
def set_command_name(cmd_name)
|
1291
1340
|
@command_name = cmd_name
|
1292
1341
|
Morpheus::Cli::CliRegistry.add(self, self.command_name)
|
@@ -9,15 +9,20 @@ class Morpheus::Cli::CurlCommand
|
|
9
9
|
set_command_hidden
|
10
10
|
|
11
11
|
def handle(args)
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
# support syntax for arbitrary curl args after " -- "
|
13
|
+
# eg. curl /api/instances -- -ksv
|
14
|
+
split_index = args.index("--")
|
15
|
+
curl_args = []
|
16
|
+
if split_index
|
17
|
+
if args.length > (split_index + 1)
|
18
|
+
curl_args = args[(split_index + 1)..-1]
|
19
|
+
end
|
20
|
+
args = args[0..(split_index - 1)]
|
21
|
+
end
|
15
22
|
curl_method = nil
|
16
23
|
curl_data = nil
|
17
24
|
curl_verbsose = false
|
18
25
|
show_progress = false
|
19
|
-
# puts "args is : #{args}"
|
20
|
-
# puts "curl_args is : #{curl_args}"
|
21
26
|
options = {}
|
22
27
|
optparse = Morpheus::Cli::OptionParser.new do|opts|
|
23
28
|
opts.banner = "Usage: morpheus curl [path] -- [*args]"
|
@@ -36,7 +41,7 @@ class Morpheus::Cli::CurlCommand
|
|
36
41
|
opts.on( '--progress', '--progress', "Display progress output by excluding the -s option." ) do
|
37
42
|
show_progress = true
|
38
43
|
end
|
39
|
-
build_common_options(opts, options, [:dry_run, :remote])
|
44
|
+
build_common_options(opts, options, [:dry_run, :json, :remote])
|
40
45
|
opts.add_hidden_option('--curl')
|
41
46
|
#opts.add_hidden_option('--scrub')
|
42
47
|
opts.footer = <<-EOT
|
@@ -98,16 +103,27 @@ EOT
|
|
98
103
|
end
|
99
104
|
curl_cmd << " \"#{url}\""
|
100
105
|
if @access_token
|
101
|
-
|
106
|
+
if !(options[:headers] && options[:headers]['Authorization'])
|
107
|
+
curl_cmd << " -H \"Authorization: Bearer #{@access_token}\""
|
108
|
+
end
|
102
109
|
end
|
103
110
|
if curl_data
|
104
111
|
#todo: curl_data.gsub("'","\\'")
|
105
112
|
curl_cmd << " --data '#{curl_data}'"
|
113
|
+
if api_path !~ /^\/?oauth/
|
114
|
+
if !(options[:headers] && options[:headers]['Content-Type'])
|
115
|
+
curl_cmd << " -H \"Content-Type: application/json\""
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
if options[:headers]
|
120
|
+
options[:headers].each do |k,v|
|
121
|
+
curl_cmd << " -H \"#{k}: #{v}\""
|
122
|
+
end
|
106
123
|
end
|
107
124
|
if !curl_args.empty?
|
108
125
|
curl_cmd << " " + curl_args.join(' ')
|
109
126
|
end
|
110
|
-
|
111
127
|
# Morpheus::Logging::DarkPrinter.puts "#{curl_cmd}" if Morpheus::Logging.debug?
|
112
128
|
curl_cmd_str = options[:scrub] ? Morpheus::Logging.scrub_message(curl_cmd) : curl_cmd
|
113
129
|
|
@@ -124,16 +140,14 @@ EOT
|
|
124
140
|
print reset
|
125
141
|
# print result
|
126
142
|
curl_output = `#{curl_cmd}`
|
127
|
-
if options[:pretty]
|
143
|
+
if options[:pretty] || options[:json]
|
128
144
|
output_lines = curl_output.split("\n")
|
129
145
|
last_line = output_lines.pop
|
130
146
|
if output_lines.size > 0
|
131
147
|
puts output_lines.join("\n")
|
132
148
|
end
|
133
149
|
begin
|
134
|
-
|
135
|
-
json_string = JSON.pretty_generate(json_data)
|
136
|
-
puts json_string
|
150
|
+
puts as_json(JSON.parse(last_line), options)
|
137
151
|
rescue => ex
|
138
152
|
Morpheus::Logging::DarkPrinter.puts "failed to parse curl result as JSON data Error: #{ex.message}" if Morpheus::Logging.debug?
|
139
153
|
puts last_line
|
@@ -6,7 +6,9 @@ require 'morpheus/cli/cli_command'
|
|
6
6
|
class Morpheus::Cli::HistoryCommand
|
7
7
|
include Morpheus::Cli::CliCommand
|
8
8
|
set_command_name :'history'
|
9
|
-
|
9
|
+
set_command_description "View morpheus shell command history"
|
10
|
+
# hidden for now because it is a shell command, shouldnt just be shell command though
|
11
|
+
set_command_hidden
|
10
12
|
|
11
13
|
# todo: support all the other :list options too, not just max
|
12
14
|
# AND start logging every terminal command, not just shell...
|
@@ -9,7 +9,7 @@ class Morpheus::Cli::ManCommand
|
|
9
9
|
|
10
10
|
# this should be read only anyway...
|
11
11
|
@@default_editor = "less" # ENV['EDITOR']
|
12
|
-
|
12
|
+
|
13
13
|
def handle(args)
|
14
14
|
options = {}
|
15
15
|
regenerate = false
|
@@ -28,6 +28,12 @@ class Morpheus::Cli::ManCommand
|
|
28
28
|
opts.on('-g','--generate', "Regenerate the manual file") do
|
29
29
|
regenerate = true
|
30
30
|
end
|
31
|
+
opts.on('-o','--out FILE', "Write manual file to a custom location") do |val|
|
32
|
+
options[:outfile] = val
|
33
|
+
end
|
34
|
+
opts.on('--overwrite', '--overwrite', "Overwrite output file if it already exists.") do |val|
|
35
|
+
options[:overwrite] = true
|
36
|
+
end
|
31
37
|
opts.on('-q','--quiet', "Do not open manual, for use with the -g option.") do
|
32
38
|
options[:quiet] = true
|
33
39
|
end
|
@@ -47,7 +53,8 @@ class Morpheus::Cli::ManCommand
|
|
47
53
|
end
|
48
54
|
opts.footer = <<-EOT
|
49
55
|
Open the morpheus manual located at #{Morpheus::Cli::ManCommand.man_file_path}
|
50
|
-
The -g
|
56
|
+
The -g option can be used to regenerate the file.
|
57
|
+
The --out FILE option be used to write the manual file to a custom location.
|
51
58
|
EOT
|
52
59
|
end
|
53
60
|
optparse.parse!(args)
|
@@ -65,18 +72,35 @@ EOT
|
|
65
72
|
end
|
66
73
|
|
67
74
|
fn = Morpheus::Cli::ManCommand.man_file_path
|
75
|
+
if options[:outfile]
|
76
|
+
regenerate = true
|
77
|
+
fn = File.expand_path(options[:outfile])
|
78
|
+
if File.directory?(fn)
|
79
|
+
# if you give me a directory, could still work and use the default filename
|
80
|
+
# fn = File.join(fn, "CLI-Manual-#{Morpheus::Cli::VERSION}.md")
|
81
|
+
# raise_command_error "outfile is invalid. It is the name of an existing directory: #{fn}"
|
82
|
+
print_error "#{red}Output file '#{fn}' is invalid.#{reset}\n"
|
83
|
+
print_error "#{red}It is the name of an existing directory.#{reset}\n"
|
84
|
+
return 1
|
85
|
+
end
|
86
|
+
if File.exists?(fn) && options[:overwrite] != true
|
87
|
+
print_error "#{red}Output file '#{fn}' already exists.#{reset}\n"
|
88
|
+
print_error "#{red}Use --overwrite to overwrite the existing file.#{reset}\n"
|
89
|
+
return 1
|
90
|
+
end
|
91
|
+
end
|
92
|
+
exit_code, err = 0, nil
|
68
93
|
if regenerate || !File.exists?(fn)
|
69
94
|
#Morpheus::Logging::DarkPrinter.puts "generating manual #{fn} ..." if Morpheus::Logging.debug? && !options[:quiet]
|
70
|
-
Morpheus::Cli::ManCommand.generate_manual(options)
|
95
|
+
exit_code, err = Morpheus::Cli::ManCommand.generate_manual(options)
|
71
96
|
end
|
72
97
|
|
73
98
|
if options[:quiet]
|
74
|
-
return
|
99
|
+
return exit_code, err
|
75
100
|
end
|
76
101
|
|
77
102
|
Morpheus::Logging::DarkPrinter.puts "opening manual file #{fn}" if Morpheus::Logging.debug? && !options[:quiet]
|
78
103
|
|
79
|
-
|
80
104
|
if open_as_link # not used atm
|
81
105
|
link = "file://#{fn}"
|
82
106
|
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
|
@@ -138,6 +162,14 @@ EOT
|
|
138
162
|
# todo: use pandoc or something else to convert the CLI-Manual.md to a man page
|
139
163
|
# and install it, so the os command `man morpheus` will work too.
|
140
164
|
fn = man_file_path()
|
165
|
+
if options[:outfile]
|
166
|
+
fn = File.expand_path(options[:outfile])
|
167
|
+
if File.exists?(fn) && options[:overwrite] != true
|
168
|
+
print_error "#{red}Output file '#{options[:outfile]}' already exists.#{reset}\n"
|
169
|
+
print_error "#{red}Use --overwrite to overwrite the existing file.#{reset}\n"
|
170
|
+
return 1, "output file already exists"
|
171
|
+
end
|
172
|
+
end
|
141
173
|
if !Dir.exists?(File.dirname(fn))
|
142
174
|
FileUtils.mkdir_p(File.dirname(fn))
|
143
175
|
end
|
@@ -153,7 +185,7 @@ EOT
|
|
153
185
|
begin
|
154
186
|
|
155
187
|
manpage.print <<-ENDTEXT
|
156
|
-
|
188
|
+
#{prog_name} v#{Morpheus::Cli::VERSION}
|
157
189
|
|
158
190
|
## NAME
|
159
191
|
|
@@ -170,17 +202,17 @@ morpheus v#{Morpheus::Cli::VERSION}
|
|
170
202
|
This is a command line interface for managing a Morpheus Appliance.
|
171
203
|
All communication with the remote appliance is done via the Morpheus API.
|
172
204
|
|
173
|
-
|
205
|
+
Use the command `#{prog_name} remote add` to connect to your Morpheus appliance.
|
174
206
|
|
175
207
|
To learn more, visit https://github.com/gomorpheus/morpheus-cli/wiki/Getting-Started
|
176
208
|
|
177
|
-
To learn more about the Morpheus Appliance, visit https://www.morpheusdata.com
|
209
|
+
To learn more about the Morpheus Appliance, visit https://www.morpheusdata.com
|
178
210
|
|
179
211
|
To learn more about the Morpheus API, visit https://apidocs.morpheusdata.com
|
180
212
|
|
181
213
|
## GLOBAL OPTIONS
|
182
214
|
|
183
|
-
|
215
|
+
There are several global options available.
|
184
216
|
|
185
217
|
-v, --version Print the version.
|
186
218
|
--noprofile Do not read and execute the personal initialization script .morpheus_profile
|
@@ -190,30 +222,42 @@ morpheus v#{Morpheus::Cli::VERSION}
|
|
190
222
|
|
191
223
|
## COMMON OPTIONS
|
192
224
|
|
193
|
-
There are
|
225
|
+
There are many common options that are supported by a most commands.
|
194
226
|
|
195
227
|
-O, --option OPTION Option value in the format -O var="value" (deprecated soon in favor of first class options)
|
196
228
|
-N, --no-prompt Skip prompts. Use default values for all optional fields.
|
229
|
+
--payload FILE Payload from a local JSON or YAML file, skip all prompting
|
230
|
+
--payload-dir DIRECTORY Payload from a local directory containing 1-N JSON or YAML files, skip all prompting
|
231
|
+
--payload-json JSON Payload JSON, skip all prompting
|
232
|
+
--payload-yaml YAML Payload YAML, skip all prompting
|
197
233
|
-j, --json JSON Output
|
198
234
|
-d, --dry-run Dry Run, print the API request instead of executing it
|
199
|
-
|
200
|
-
|
201
|
-
-
|
202
|
-
|
235
|
+
--curl Dry Run to output API request as a curl command.
|
236
|
+
--scrub Mask secrets in output, such as the Authorization header. For use with --curl and --dry-run.
|
237
|
+
-r, --remote REMOTE Remote name. The current remote is used by default.
|
238
|
+
--remote-url URL Remote url. This allows adhoc requests instead of using a configured remote.
|
239
|
+
-T, --token TOKEN Access token for authentication with --remote. Saved credentials are used by default.
|
240
|
+
-U, --username USERNAME Username for authentication.
|
241
|
+
-P, --password PASSWORD Password for authentication.
|
242
|
+
-I, --insecure Allow insecure HTTPS communication. i.e. bad SSL certificate.
|
243
|
+
-H, --header HEADER Additional HTTP header to include with requests.
|
244
|
+
--timeout SECONDS Timeout for api requests. Default is typically 30 seconds.
|
245
|
+
-y, --yes Auto Confirm
|
246
|
+
-q, --quiet No Output, do not print to stdout
|
203
247
|
|
204
248
|
## MORPHEUS COMMANDS
|
205
249
|
|
206
|
-
|
207
|
-
|
250
|
+
The morpheus executable is divided into commands.
|
251
|
+
Each morpheus command may have 0-N sub-commands that it supports.
|
208
252
|
Commands generally map to the functionality provided in the Morpheus UI.
|
209
253
|
|
210
254
|
You can get help for any morpheus command by using the -h option.
|
211
255
|
|
212
|
-
The available commands and their options are
|
256
|
+
The available commands and their options are documented below.
|
213
257
|
ENDTEXT
|
214
258
|
|
215
259
|
terminal = Morpheus::Terminal.new($stdin, manpage)
|
216
|
-
Morpheus::Logging::DarkPrinter.puts "appending command help
|
260
|
+
Morpheus::Logging::DarkPrinter.puts "appending command help `#{prog_name} --help`" if Morpheus::Logging.debug? && !options[:quiet]
|
217
261
|
|
218
262
|
manpage.print "\n"
|
219
263
|
manpage.print "## morpheus\n"
|
@@ -226,7 +270,7 @@ ENDTEXT
|
|
226
270
|
Morpheus::Cli::CliRegistry.all.keys.sort.each do |cmd|
|
227
271
|
cmd_klass = Morpheus::Cli::CliRegistry.instance.get(cmd)
|
228
272
|
cmd_instance = cmd_klass.new
|
229
|
-
Morpheus::Logging::DarkPrinter.puts "appending command help
|
273
|
+
Morpheus::Logging::DarkPrinter.puts "appending command help `#{prog_name} #{cmd} --help`" if Morpheus::Logging.debug? && !options[:quiet]
|
230
274
|
#help_cmd = "morpheus #{cmd} --help"
|
231
275
|
#help_output = `#{help_cmd}`
|
232
276
|
manpage.print "\n"
|
@@ -243,7 +287,7 @@ ENDTEXT
|
|
243
287
|
subcommands = cmd_klass.visible_subcommands
|
244
288
|
if subcommands && subcommands.size > 0
|
245
289
|
subcommands.sort.each do |subcommand, subcommand_method|
|
246
|
-
Morpheus::Logging::DarkPrinter.puts "appending command help
|
290
|
+
Morpheus::Logging::DarkPrinter.puts "appending command help `#{prog_name} #{cmd} #{subcommand} --help`" if Morpheus::Logging.debug? && !options[:quiet]
|
247
291
|
manpage.print "\n"
|
248
292
|
manpage.print "#### morpheus #{cmd} #{subcommand}\n"
|
249
293
|
manpage.print "\n"
|
@@ -289,7 +333,7 @@ morpheus> remote list
|
|
289
333
|
Morpheus Appliances
|
290
334
|
==================
|
291
335
|
|
292
|
-
You have no appliances configured. See the
|
336
|
+
You have no appliances configured. See the `#{prog_name} remote add` command.
|
293
337
|
|
294
338
|
```
|
295
339
|
|
@@ -319,11 +363,10 @@ The `appliances` YAML file contains a list of known appliances, keyed by name.
|
|
319
363
|
Example:
|
320
364
|
```yaml
|
321
365
|
:qa:
|
322
|
-
:host: https://qa.
|
366
|
+
:host: https://qa.mymorpheus.com
|
323
367
|
:active: true
|
324
368
|
:production:
|
325
|
-
:host: https://
|
326
|
-
:active: false
|
369
|
+
:host: https://mymorpheus.com
|
327
370
|
```
|
328
371
|
|
329
372
|
### credentials file
|
@@ -349,7 +392,7 @@ This may be inhibited by using the `--noprofile` option.
|
|
349
392
|
|
350
393
|
### .morpheusrc file
|
351
394
|
|
352
|
-
When started as an interactive shell with the
|
395
|
+
When started as an interactive shell with the `#{prog_name} shell` command,
|
353
396
|
Morpheus reads and executes `$MORPHEUS_CLI_HOME/.morpheusrc` (if it exists). This may be inhibited by using the `--norc` option.
|
354
397
|
|
355
398
|
An example startup script might look like this:
|
@@ -357,20 +400,11 @@ An example startup script might look like this:
|
|
357
400
|
```
|
358
401
|
# .morpheusrc
|
359
402
|
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
# greeting
|
367
|
-
echo "Welcome back human, have fun!"
|
368
|
-
|
369
|
-
# print current user information
|
370
|
-
whoami
|
371
|
-
|
372
|
-
# print the list of instances in our cloud
|
373
|
-
our-instances
|
403
|
+
set-prompt "%cyan%username%reset@%magenta%remote %cyanmorpheus> %reset"
|
404
|
+
version
|
405
|
+
remote current
|
406
|
+
echo "Welcome back %username"
|
407
|
+
echo
|
374
408
|
|
375
409
|
```
|
376
410
|
|
@@ -383,7 +417,7 @@ ENDTEXT
|
|
383
417
|
terminal = Morpheus::Terminal.new()
|
384
418
|
end
|
385
419
|
|
386
|
-
return
|
420
|
+
return 0, nil
|
387
421
|
end
|
388
422
|
|
389
423
|
end
|