morpheus-cli 3.6.11 → 3.6.12
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/lib/morpheus/cli/commands/standard/benchmark_command.rb +14 -2
- data/lib/morpheus/cli/commands/standard/coloring_command.rb +14 -2
- data/lib/morpheus/cli/commands/standard/debug_command.rb +16 -1
- data/lib/morpheus/cli/commands/standard/history_command.rb +2 -2
- data/lib/morpheus/cli/commands/standard/log_level_command.rb +5 -1
- data/lib/morpheus/cli/cypher_command.rb +3 -2
- data/lib/morpheus/cli/shell.rb +61 -10
- data/lib/morpheus/cli/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 662d9e93e1e871b6f955e6db6da0534fd9018f303fa9f77be33b4985e9b7aeff
|
4
|
+
data.tar.gz: e9728d099bc08d4f9a2ffbd1292e8d9d8ebe337e56673e10673fd464e9d03a46
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e55742378c6bd60dff897dad5b773e8127e82eae92b77b896954beb419b0853c5a576865ead400cad65fa4a6617a2b6d8e308a9d5d604725ada4b7dd1d49550
|
7
|
+
data.tar.gz: b8237f9eae9f570e0efc86ebb05f322a723bcf9b349c9621d7335732e96009d249d0089c88e6a41e26f51c611f5130c44058cbca3e7614393a9469bbfeae0ed0
|
@@ -45,9 +45,15 @@ EOT
|
|
45
45
|
puts_error "wrong number of arguments, expected 0 and got #{args.count} #{args.join(' ')}\n#{optparse}"
|
46
46
|
return 1
|
47
47
|
end
|
48
|
+
benchmark_was_enabled = Morpheus::Benchmarking.enabled
|
48
49
|
Morpheus::Benchmarking.enabled = true
|
49
50
|
my_terminal.benchmarking = Morpheus::Benchmarking.enabled
|
50
|
-
|
51
|
+
unless options[:quiet]
|
52
|
+
# if benchmark_was_enabled == false
|
53
|
+
# Morpheus::Logging::DarkPrinter.puts "benchmark enabled" if Morpheus::Logging.debug?
|
54
|
+
# end
|
55
|
+
puts "#{cyan}benchmark: #{green}on#{reset}"
|
56
|
+
end
|
51
57
|
return 0
|
52
58
|
end
|
53
59
|
|
@@ -69,9 +75,15 @@ EOT
|
|
69
75
|
puts_error "wrong number of arguments, expected 0 and got #{args.count} #{args.join(' ')}\n#{optparse}"
|
70
76
|
return 1
|
71
77
|
end
|
78
|
+
benchmark_was_enabled = Morpheus::Benchmarking.enabled
|
72
79
|
Morpheus::Benchmarking.enabled = false
|
73
80
|
my_terminal.benchmarking = Morpheus::Benchmarking.enabled
|
74
|
-
|
81
|
+
unless options[:quiet]
|
82
|
+
# if benchmark_was_enabled == true
|
83
|
+
# Morpheus::Logging::DarkPrinter.puts "benchmark disabled" if Morpheus::Logging.debug?
|
84
|
+
# end
|
85
|
+
puts "#{cyan}benchmark: #{dark}off#{reset}"
|
86
|
+
end
|
75
87
|
return 0
|
76
88
|
end
|
77
89
|
|
@@ -15,29 +15,35 @@ class Morpheus::Cli::ColoringCommand
|
|
15
15
|
optparse = Morpheus::Cli::OptionParser.new do|opts|
|
16
16
|
opts.banner = "Usage: morpheus #{command_name} [on|off]"
|
17
17
|
#build_common_options(opts, options, [])
|
18
|
+
opts.on('-q','--quiet', "No Output, do not print to stdout") do
|
19
|
+
options[:quiet] = true
|
20
|
+
end
|
18
21
|
opts.on('-h', '--help', "Print this help" ) do
|
19
22
|
puts opts
|
20
23
|
exit
|
21
24
|
end
|
22
25
|
opts.footer = "Enable [on] or Disable [off] ANSI Colors for all output.\n" +
|
23
26
|
"Use [on?] or [off?] to print the current value and exit accordingly." + "\n" +
|
24
|
-
"
|
27
|
+
"Passing no arguments is the same as `#{command_name} on`"
|
25
28
|
end
|
26
29
|
optparse.parse!(args)
|
27
30
|
if args.count > 1
|
28
31
|
raise_command_error "wrong number of arguments, expected 0-1 and got (#{args.count}) #{args.join(' ')}\n#{optparse}"
|
29
32
|
end
|
30
33
|
|
34
|
+
coloring_was_enabled = Term::ANSIColor::coloring?
|
31
35
|
exit_code = 0
|
32
36
|
|
33
37
|
if args.count == 0
|
34
|
-
#
|
38
|
+
# no args means turn it on.
|
39
|
+
Term::ANSIColor::coloring = true
|
35
40
|
else
|
36
41
|
subcmd = args[0].to_s.strip
|
37
42
|
if subcmd == "on"
|
38
43
|
Term::ANSIColor::coloring = true
|
39
44
|
elsif subcmd == "off"
|
40
45
|
Term::ANSIColor::coloring = false
|
46
|
+
|
41
47
|
elsif subcmd == "on?"
|
42
48
|
exit_code = Term::ANSIColor::coloring? ? 0 : 1
|
43
49
|
elsif subcmd == "off?"
|
@@ -49,8 +55,14 @@ class Morpheus::Cli::ColoringCommand
|
|
49
55
|
end
|
50
56
|
unless options[:quiet]
|
51
57
|
if Term::ANSIColor::coloring?
|
58
|
+
if coloring_was_enabled == false
|
59
|
+
Morpheus::Logging::DarkPrinter.puts "coloring enabled" if Morpheus::Logging.debug?
|
60
|
+
end
|
52
61
|
puts "#{cyan}coloring: #{bold}#{green}on#{reset}"
|
53
62
|
else
|
63
|
+
if coloring_was_enabled == true
|
64
|
+
Morpheus::Logging::DarkPrinter.puts "coloring disabled" if Morpheus::Logging.debug?
|
65
|
+
end
|
54
66
|
puts "coloring: off"
|
55
67
|
end
|
56
68
|
end
|
@@ -14,23 +14,30 @@ class Morpheus::Cli::DebugCommand
|
|
14
14
|
optparse = Morpheus::Cli::OptionParser.new do|opts|
|
15
15
|
opts.banner = "Usage: morpheus #{command_name} [on|off]"
|
16
16
|
#build_common_options(opts, options, [])
|
17
|
+
opts.on('-q','--quiet', "No Output, do not print to stdout") do
|
18
|
+
options[:quiet] = true
|
19
|
+
end
|
17
20
|
opts.on('-h', '--help', "Print this help" ) do
|
18
21
|
puts opts
|
19
22
|
exit
|
20
23
|
end
|
21
24
|
opts.footer = "Enable [on] or Disable [off] debugging for all output.\n" +
|
22
25
|
"Use [on?] or [off?] to print the current value and exit accordingly." + "\n" +
|
23
|
-
"
|
26
|
+
"Passing no arguments is the same as `#{command_name} on`"
|
24
27
|
end
|
25
28
|
optparse.parse!(args)
|
26
29
|
if args.count > 1
|
27
30
|
raise_command_error "wrong number of arguments, expected 0-1 and got (#{args.count}) #{args.join(' ')}\n#{optparse}"
|
28
31
|
end
|
29
32
|
|
33
|
+
debug_was_enabled = Morpheus::Logging.debug?
|
30
34
|
exit_code = 0
|
31
35
|
|
32
36
|
if args.count == 0
|
33
37
|
# just print
|
38
|
+
# no way, debug means turn it on.
|
39
|
+
Morpheus::Logging.set_log_level(Morpheus::Logging::Logger::DEBUG)
|
40
|
+
::RestClient.log = Morpheus::Logging.debug? ? Morpheus::Logging::DarkPrinter.instance : nil
|
34
41
|
else
|
35
42
|
subcmd = args[0].to_s.strip
|
36
43
|
if subcmd == "on"
|
@@ -43,6 +50,8 @@ class Morpheus::Cli::DebugCommand
|
|
43
50
|
exit_code = Morpheus::Logging.debug? ? 0 : 1
|
44
51
|
elsif subcmd == "off?"
|
45
52
|
exit_code = Morpheus::Logging.debug? ? 1 : 0
|
53
|
+
elsif subcmd == "status"
|
54
|
+
# just print current value
|
46
55
|
else
|
47
56
|
puts optparse
|
48
57
|
return 127
|
@@ -50,8 +59,14 @@ class Morpheus::Cli::DebugCommand
|
|
50
59
|
end
|
51
60
|
unless options[:quiet]
|
52
61
|
if Morpheus::Logging.debug?
|
62
|
+
if debug_was_enabled == false
|
63
|
+
Morpheus::Logging::DarkPrinter.puts "debug enabled" if Morpheus::Logging.debug?
|
64
|
+
end
|
53
65
|
puts "#{cyan}debug: #{green}on#{reset}"
|
54
66
|
else
|
67
|
+
if debug_was_enabled == true
|
68
|
+
Morpheus::Logging::DarkPrinter.puts "debug disabled" if Morpheus::Logging.debug?
|
69
|
+
end
|
55
70
|
puts "#{cyan}debug: #{dark}off#{reset}"
|
56
71
|
end
|
57
72
|
end
|
@@ -47,8 +47,8 @@ EOT
|
|
47
47
|
Morpheus::Cli::Shell.instance.flush_history
|
48
48
|
return 0
|
49
49
|
else
|
50
|
-
|
51
|
-
Morpheus::Cli::Shell.instance.print_history(
|
50
|
+
# supports all the :list options
|
51
|
+
Morpheus::Cli::Shell.instance.print_history(options)
|
52
52
|
return 0
|
53
53
|
end
|
54
54
|
end
|
@@ -13,6 +13,9 @@ class Morpheus::Cli::LogLevelCommand
|
|
13
13
|
optparse = Morpheus::Cli::OptionParser.new do|opts|
|
14
14
|
opts.banner = "Usage: morpheus #{command_name} [debug|info|0|1]"
|
15
15
|
#build_common_options(opts, options, [])
|
16
|
+
opts.on('-q','--quiet', "No Output, do not print to stdout") do
|
17
|
+
options[:quiet] = true
|
18
|
+
end
|
16
19
|
opts.on('-h', '--help', "Print this help" ) do
|
17
20
|
puts opts
|
18
21
|
exit
|
@@ -33,10 +36,11 @@ EOT
|
|
33
36
|
puts optparse
|
34
37
|
return false
|
35
38
|
end
|
39
|
+
debug_was_enabled = Morpheus::Logging.debug?
|
36
40
|
if ["debug", "0"].include?(args[0].to_s.strip.downcase)
|
37
41
|
Morpheus::Logging.set_log_level(Morpheus::Logging::Logger::DEBUG)
|
38
42
|
::RestClient.log = Morpheus::Logging.debug? ? Morpheus::Logging::DarkPrinter.instance : nil
|
39
|
-
Morpheus::Logging::DarkPrinter.puts "debug enabled"
|
43
|
+
Morpheus::Logging::DarkPrinter.puts "debug enabled" unless debug_was_enabled
|
40
44
|
elsif ["info", "1"].include?(args[0].to_s.strip.downcase)
|
41
45
|
Morpheus::Logging.set_log_level(Morpheus::Logging::Logger::INFO)
|
42
46
|
::RestClient.log = Morpheus::Logging.debug? ? Morpheus::Logging::DarkPrinter.instance : nil
|
@@ -383,7 +383,6 @@ class Morpheus::Cli::CypherCommand
|
|
383
383
|
end
|
384
384
|
existing_cypher = nil
|
385
385
|
json_response = @cypher_interface.list(item_key)
|
386
|
-
puts "json_response: #{json_response}"
|
387
386
|
if json_response["data"] && json_response["data"]["keys"]
|
388
387
|
existing_cypher = json_response["data"]["keys"].find {|k| k == item_key }
|
389
388
|
end
|
@@ -481,7 +480,7 @@ key - Generates a Base 64 encoded AES Key of specified bit length in the key pat
|
|
481
480
|
|
482
481
|
def cypher_ttl_help
|
483
482
|
"""
|
484
|
-
Lease time in seconds
|
483
|
+
Lease time in seconds
|
485
484
|
Quick Second Time Reference:
|
486
485
|
Hour: 3600
|
487
486
|
Day: 86400
|
@@ -489,6 +488,8 @@ Week: 604800
|
|
489
488
|
Month (30 days): 2592000
|
490
489
|
Year: 31536000
|
491
490
|
This can also be passed in abbreviated format with the unit as the suffix. eg. 32d, 90s, 5y
|
491
|
+
This can be passed as 0 to disable expiration and never expire.
|
492
|
+
The default is 32 days (2764800).
|
492
493
|
"""
|
493
494
|
end
|
494
495
|
|
data/lib/morpheus/cli/shell.rb
CHANGED
@@ -681,22 +681,73 @@ class Morpheus::Cli::Shell
|
|
681
681
|
nil
|
682
682
|
end
|
683
683
|
end
|
684
|
-
|
685
|
-
|
686
|
-
|
684
|
+
|
685
|
+
# load_history_commands paginates and sorts the command history
|
686
|
+
# the most recent 25 are returned by default.
|
687
|
+
# @return Hash like {:commands => [], :command_count => total}
|
688
|
+
def load_history_commands(options={})
|
689
|
+
options[:phrase] ||= nil
|
690
|
+
options[:sort] = options[:sort] ? options[:sort].to_sym : :number
|
691
|
+
options[:direction] ||= 'asc'
|
692
|
+
options[:offset] = options[:offset].to_i > 0 ? options[:offset].to_i : 0
|
693
|
+
options[:max] = options[:max].to_i > 0 ? options[:max].to_i : 25
|
694
|
+
|
687
695
|
load_history_from_log_file if !@history
|
688
|
-
|
689
|
-
|
690
|
-
|
696
|
+
|
697
|
+
# collect records as [{:number => 1, :command => "instances list"}, etc]
|
698
|
+
history_records = []
|
699
|
+
history_count = 0
|
700
|
+
if options[:sort].to_sym == :command
|
701
|
+
sort_key = :command
|
691
702
|
else
|
692
|
-
|
703
|
+
sort_key = :number
|
704
|
+
end
|
705
|
+
if options[:phrase] || sort_key != :number
|
706
|
+
# this could be a large object...need to index our shell_history file lol
|
707
|
+
history_records = @history.keys.collect { |k| {number: k, command: @history[k]} }
|
708
|
+
history_records = history_records.sort {|x,y| x[sort_key] <=> y[sort_key] }
|
709
|
+
if options[:phrase]
|
710
|
+
history_records = history_records.select {|it| it[:command].include?(options[:phrase]) || it[:number].to_s == options[:phrase] }
|
711
|
+
end
|
712
|
+
# get count and then slice it
|
713
|
+
command_count = history_records.size
|
714
|
+
history_records = history_records[options[:offset]..options[:max]-1]
|
715
|
+
else
|
716
|
+
# default should try to be as fast as possible..
|
717
|
+
# no searching or sorting, default order by :number works
|
718
|
+
# desc here means show oldest commands
|
719
|
+
if options[:direction] == 'desc'
|
720
|
+
if options[:offset]
|
721
|
+
cmd_numbers = @history.keys.first(options[:max] + options[:offset]).first(options[:max])
|
722
|
+
else
|
723
|
+
cmd_numbers = @history.keys.first(options[:max])
|
724
|
+
end
|
725
|
+
cmd_count = @history.keys.size
|
726
|
+
else
|
727
|
+
cmd_numbers = []
|
728
|
+
if options[:offset]
|
729
|
+
cmd_numbers = @history.keys.last(options[:max] + options[:offset]).first(options[:max])
|
730
|
+
else
|
731
|
+
cmd_numbers = @history.keys.last(options[:max])
|
732
|
+
end
|
733
|
+
history_records = cmd_numbers.collect { |k| {number: k, command: @history[k]} }
|
734
|
+
command_count = @history.size
|
735
|
+
end
|
693
736
|
end
|
737
|
+
return {:commands => history_records, :command_count => command_count}
|
738
|
+
end
|
739
|
+
|
740
|
+
def print_history(options={})
|
741
|
+
history_result = load_history_commands(options)
|
742
|
+
history_records = history_result[:commands]
|
743
|
+
command_count = history_result[:command_count]
|
694
744
|
print cyan
|
695
|
-
|
696
|
-
|
697
|
-
puts "#{cmd_number.to_s.rjust(3, ' ')} #{cmd}"
|
745
|
+
history_records.each do |history_record|
|
746
|
+
puts "#{history_record[:number].to_s.rjust(3, ' ')} #{history_record[:command]}"
|
698
747
|
end
|
748
|
+
#print_results_pagination({size:history_records.size,total:command_count.to_i}, {:label => "command", :n_label => "commands"})
|
699
749
|
print reset
|
750
|
+
#print "\n"
|
700
751
|
return 0
|
701
752
|
end
|
702
753
|
|
data/lib/morpheus/cli/version.rb
CHANGED