morpheus-cli 3.6.14 → 3.6.15

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aec984aa936c4514cf97141863e02468799a227e98d1f09862a5f7be773cd512
4
- data.tar.gz: d491b1541ae9e74d02ba9857a475b7ab15ac7eac0901c55937bb07b5d953be71
3
+ metadata.gz: 44cd5f86f718d01477f1d822a42fbf33374ad0339e080b57d589040bcad06dd5
4
+ data.tar.gz: 3b43a3da6bfa2b65e683a1696ec3d39ef4f17acde0d388dd9004ab1416ad9bb8
5
5
  SHA512:
6
- metadata.gz: 4d1da2f8325d05492b0e03ce8a28e7a6301361b84ce78526761de0a86a78a1d2003e11abb2fb00b4f520016cbef8a3b9a4b72aee85fe7034d9cf33505bf3b7f4
7
- data.tar.gz: 1916a80f9e8b895806e40f3c29f47139b2cf2d97ad91bef6f91e000bb8233defcd71725bc09cd986e0730eba39aff45667afd9d4891e142709c39966f8da934d
6
+ metadata.gz: 12da78b947b3aec266e206833af10ec1a068efe9aab6e92d01b0d266ff36c06a37d371f5e16bb7d9d9c96cf43daa2b7ce8feed7989d4bc72b2bc065d2a73014c
7
+ data.tar.gz: a7e99aa6d071b30f64344505c2cce44204f1d11dc255e253c4c750798a7483074dee8162a206ec59bd04be94f9bbc4fc2e09f48b048754dedbccf49bd1896e93
@@ -124,7 +124,7 @@ module Morpheus::Benchmarking
124
124
  start_benchmark(opts)
125
125
  if block_given?
126
126
  result = block.call()
127
- # exit_code, err = Morpheus::Cli::CliCommand.parse_command_result(result)
127
+ # exit_code, err = Morpheus::Cli.parse_command_result(result)
128
128
  if result.is_a?(Array)
129
129
  exit_code = result[0]
130
130
  err = result[0]
@@ -39,6 +39,36 @@ module Morpheus
39
39
  return @@is_windows
40
40
  end
41
41
 
42
+ def self.parse_command_result(cmd_result)
43
+ exit_code, err = nil, nil
44
+ if cmd_result.is_a?(Array)
45
+ exit_code, err = cmd_result[0], cmd_result[1]
46
+ elsif cmd_result.is_a?(Hash)
47
+ exit_code, err = cmd_result[:exit_code], (cmd_result[:error] || cmd_result[:err])
48
+ end
49
+ if cmd_result == nil || cmd_result == true
50
+ exit_code = 0
51
+ elsif cmd_result == false
52
+ exit_code = 1
53
+ elsif cmd_result.is_a?(Integer)
54
+ exit_code = cmd_result
55
+ elsif cmd_result.is_a?(Float)
56
+ exit_code = cmd_result.to_i
57
+ elsif cmd_result.is_a?(String)
58
+ exit_code = cmd_result.to_i
59
+ else
60
+ if cmd_result.respond_to?(:to_i)
61
+ exit_code = cmd_result.to_i
62
+ else
63
+ # happens for aliases right now.. and execution flow probably, need to handle Array
64
+ # uncomment to track them down, proceed with exit 0 for now
65
+ #Morpheus::Logging::DarkPrinter.puts "debug: command #{command_name} produced an unexpected result: (#{cmd_result.class}) #{cmd_result}" if Morpheus::Logging.debug?
66
+ exit_code = 0
67
+ end
68
+ end
69
+ return exit_code, err
70
+ end
71
+
42
72
  # load all the well known commands and utilties they need
43
73
  def self.load!()
44
74
  # load interfaces
@@ -933,44 +933,8 @@ module Morpheus
933
933
  return output
934
934
  end
935
935
 
936
- def parse_command_result(cmd_result)
937
- self.class.parse_command_result(cmd_result)
938
- end
939
-
940
936
  module ClassMethods
941
937
 
942
- # Parse exit_code and err from a command result (object of some type)
943
- # returns [exit_code, err]
944
- def parse_command_result(cmd_result)
945
- exit_code, err = nil, nil
946
- if cmd_result.is_a?(Array)
947
- exit_code, err = cmd_result[0], cmd_result[1]
948
- elsif cmd_result.is_a?(Hash)
949
- exit_code, err = cmd_result[:exit_code], (cmd_result[:error] || cmd_result[:err])
950
- end
951
- if cmd_result == nil || cmd_result == true
952
- exit_code = 0
953
- elsif cmd_result == false
954
- exit_code = 1
955
- elsif cmd_result.is_a?(Integer)
956
- exit_code = cmd_result
957
- elsif cmd_result.is_a?(Float)
958
- exit_code = cmd_result.to_i
959
- elsif cmd_result.is_a?(String)
960
- exit_code = cmd_result.to_i
961
- else
962
- if cmd_result.respond_to?(:to_i)
963
- exit_code = cmd_result.to_i
964
- else
965
- # happens for aliases right now.. and execution flow probably, need to handle Array
966
- # uncomment to track them down, proceed with exit 0 for now
967
- #Morpheus::Logging::DarkPrinter.puts "debug: command #{command_name} produced an unexpected result: (#{cmd_result.class}) #{cmd_result}" if Morpheus::Logging.debug?
968
- exit_code = 0
969
- end
970
- end
971
- return exit_code, err
972
- end
973
-
974
938
  def set_command_name(cmd_name)
975
939
  @command_name = cmd_name
976
940
  Morpheus::Cli::CliRegistry.add(self, self.command_name)
@@ -322,7 +322,7 @@ EOT
322
322
  # exit_code, err = my_terminal.execute(cmd)
323
323
  # do this way until terminal supports expressions
324
324
  cmd_result = execute_commands_as_expression(cmd)
325
- exit_code, err = parse_command_result(cmd_result)
325
+ exit_code, err = Morpheus::Cli.parse_command_result(cmd_result)
326
326
 
327
327
  benchmark_record = stop_benchmark(exit_code, err)
328
328
  Morpheus::Logging::DarkPrinter.puts(cyan + dark + benchmark_record.msg) if benchmark_record
@@ -373,13 +373,13 @@ EOT
373
373
  if flow_cmd == '&&'
374
374
  # AND operator
375
375
  current_operator = flow_cmd
376
- exit_code, cmd_err = parse_command_result(previous_command_result)
376
+ exit_code, cmd_err = Morpheus::Cli.parse_command_result(previous_command_result)
377
377
  if exit_code != 0
378
378
  still_executing = false
379
379
  end
380
380
  elsif flow_cmd == '||' # or with previous command
381
381
  current_operator = flow_cmd
382
- exit_code, err = parse_command_result(previous_command_result)
382
+ exit_code, err = Morpheus::Cli.parse_command_result(previous_command_result)
383
383
  if exit_code == 0
384
384
  still_executing = false
385
385
  end
@@ -64,7 +64,7 @@ class Morpheus::Cli::Groups
64
64
  active_group = groups.find { |it| it['id'] == @active_group_id }
65
65
  active_group = active_group || find_group_by_name_or_id(@active_group_id)
66
66
  #unless @appliances.keys.size == 1
67
- print cyan, "\n# => Currently using group #{green}#{active_group['name']}#{reset}\n", reset
67
+ print cyan, "\n# => Currently using group #{active_group['name']}\n", reset
68
68
  #end
69
69
  else
70
70
  unless options[:remote]
@@ -399,12 +399,12 @@ class Morpheus::Cli::Groups
399
399
  "This sets the active group.\n" +
400
400
  "The active group will be auto-selected for use during provisioning.\n" +
401
401
  "You can still use the --group option to override this."
402
- build_common_options(opts, options, [])
402
+ build_common_options(opts, options, [:quiet, :remote])
403
403
  end
404
404
  optparse.parse!(args)
405
405
  if args.count < 1
406
406
  puts optparse
407
- exit 1
407
+ return 1
408
408
  end
409
409
  connect(options)
410
410
  begin
@@ -412,20 +412,24 @@ class Morpheus::Cli::Groups
412
412
  group = find_group_by_name_or_id(args[0])
413
413
  if !group
414
414
  print_red_alert "Group not found by name #{args[0]}"
415
- exit 1
415
+ return 1
416
416
  end
417
-
418
417
  if @active_group_id == group['id']
419
- print reset,"Already using the group #{group['name']}","\n",reset
418
+ unless options[:quiet]
419
+ print reset,"Already using the group #{group['name']}","\n",reset
420
+ end
420
421
  else
421
422
  ::Morpheus::Cli::Groups.set_active_group(@appliance_name, group['id'])
422
423
  # ::Morpheus::Cli::Groups.save_groups(@active_groups)
423
- #print cyan,"Switched active group to #{group['name']}","\n",reset
424
+ unless options[:quiet]
425
+ print cyan,"Switched active group to #{group['name']}","\n",reset
426
+ end
424
427
  #list([])
425
428
  end
429
+ return 0
426
430
  rescue RestClient::Exception => e
427
431
  print_rest_exception(e, options)
428
- exit 1
432
+ return 1
429
433
  end
430
434
 
431
435
  end
@@ -486,14 +490,15 @@ class Morpheus::Cli::Groups
486
490
  {
487
491
  active: (is_active ? "=>" : ""),
488
492
  id: group['id'],
489
- name: is_active ? "#{green}#{group['name']}#{reset}#{table_color}" : group['name'],
493
+ # name: is_active ? "#{green}#{group['name']}#{reset}#{table_color}" : group['name'],
494
+ name: group['name'],
490
495
  location: group['location'],
491
496
  cloud_count: group['zones'] ? group['zones'].size : 0,
492
497
  server_count: group['serverCount']
493
498
  }
494
499
  end
495
500
  columns = [
496
- #{:active => {:display_name => ""}},
501
+ {:active => {:display_name => ""}},
497
502
  {:id => {:width => 10}},
498
503
  {:name => {:width => 16}},
499
504
  {:location => {:width => 32}},
@@ -72,8 +72,9 @@ EOT
72
72
  else
73
73
  print cyan
74
74
  columns = [
75
- #{:active => {:display_name => "", :display_method => lambda {|it| it[:active] ? "=>" : "" } } },
76
- {:name => {display_method: lambda {|it| it[:active] ? "#{green}#{it[:name]}#{reset}#{cyan}" : it[:name] }, :width => 16 } },
75
+ {:active => {:display_name => "", :display_method => lambda {|it| it[:active] ? "=>" : "" } } },
76
+ # {:name => {display_method: lambda {|it| it[:active] ? "#{green}#{it[:name]}#{reset}#{cyan}" : it[:name] }, :width => 16 } },
77
+ {:name => {display_method: lambda {|it| it[:name] }, :width => 16 } },
77
78
  {:url => {display_method: lambda {|it| it[:host] || it[:url] }, :width => 40 } },
78
79
  {:version => lambda {|it| it[:build_version] } },
79
80
  {:status => lambda {|it| format_appliance_status(it, cyan) } },
@@ -85,7 +86,7 @@ EOT
85
86
  print reset
86
87
  if @appliance_name
87
88
  #unless appliances.keys.size == 1
88
- print cyan, "\n# => Currently using remote #{green}#{@appliance_name}#{reset}\n", reset
89
+ print cyan, "\n# => Currently using remote #{@appliance_name}\n", reset
89
90
  #end
90
91
  else
91
92
  print "\n# => No current remote appliance, see `remote use`\n", reset
@@ -287,13 +287,13 @@ class Morpheus::Cli::Shell
287
287
  if flow_cmd == '&&'
288
288
  # AND operator
289
289
  current_operator = flow_cmd
290
- exit_code, cmd_err = parse_command_result(previous_command_result)
290
+ exit_code, cmd_err = Morpheus::Cli.parse_command_result(previous_command_result)
291
291
  if exit_code != 0
292
292
  still_executing = false
293
293
  end
294
294
  elsif flow_cmd == '||' # or with previous command
295
295
  current_operator = flow_cmd
296
- exit_code, err = parse_command_result(previous_command_result)
296
+ exit_code, err = Morpheus::Cli.parse_command_result(previous_command_result)
297
297
  if exit_code == 0
298
298
  still_executing = false
299
299
  end
@@ -536,7 +536,7 @@ class Morpheus::Cli::Shell
536
536
  end
537
537
  end
538
538
  cmd_result = Morpheus::Cli::CliRegistry.exec(cmd_name, cmd_args)
539
- cmd_exit_code, cmd_err = parse_command_result(cmd_result)
539
+ cmd_exit_code, cmd_err = Morpheus::Cli.parse_command_result(cmd_result)
540
540
  benchmark_record = stop_benchmark(cmd_exit_code, cmd_err) # if benchmarking?
541
541
  Morpheus::Logging::DarkPrinter.puts(cyan + dark + benchmark_record.msg) if benchmark_record
542
542
  else
@@ -1,6 +1,6 @@
1
1
 
2
2
  module Morpheus
3
3
  module Cli
4
- VERSION = "3.6.14"
4
+ VERSION = "3.6.15"
5
5
  end
6
6
  end
@@ -382,17 +382,7 @@ module Morpheus
382
382
  else
383
383
  result = Morpheus::Cli::CliRegistry.exec(args[0], args[1..-1])
384
384
  end
385
- # todo: clean up CliCommand return values, handle a few diff types for now
386
- if result == nil || result == true || result == 0
387
- exit_code = 0
388
- elsif result == false
389
- exit_code = 1
390
- elsif result.is_a?(Array) # exit_code, err
391
- exit_code = result[0] #.to_i
392
- err = result[1]
393
- else
394
- exit_code = result #.to_i
395
- end
385
+ exit_code, err = Morpheus::Cli.parse_command_result(result)
396
386
  rescue => e
397
387
  exit_code = Morpheus::Cli::ErrorHandler.new(@stderr).handle_error(e)
398
388
  err = e
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: morpheus-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.6.14
4
+ version: 3.6.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Estes