morpheus-cli 3.6.16 → 3.6.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/morpheus/cli/commands/standard/history_command.rb +2 -1
- data/lib/morpheus/cli/shell.rb +22 -23
- data/lib/morpheus/cli/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ab0c8fe5a857968851e03071645663f2c0ca449577b3c2e62106ed9ef57c9fe
|
4
|
+
data.tar.gz: 85e741a356d27d1729eb9e51cd9be7aebe7b3f9d11f17132f342992131b6c7d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9780024822d8ff3eda9cb7ce718f3bd0fe18975e97ba6a883e88d22d4c311b72d8e2eba0de07ec265fb4789391ba3ea004737072a8b13bebb85f2a198c9d5631
|
7
|
+
data.tar.gz: 3dbdd462ee7e562561ba0d3ec94cb7fd96a2af842b610f04e3524301136ac80dd9c7d33b79cc87b0e2fdb99a3ebc33c3c0cd85986ae4da4bcbe090c1f3945e6c
|
@@ -46,7 +46,8 @@ EOT
|
|
46
46
|
return 1
|
47
47
|
end
|
48
48
|
if options[:do_flush]
|
49
|
-
|
49
|
+
command_count = Morpheus::Cli::Shell.instance.history_commands_count
|
50
|
+
unless options[:yes] || Morpheus::Cli::OptionTypes.confirm("Are you sure you want to flush your command history (#{format_number(command_count)} #{command_count == 1 ? 'command' : 'commands'})?")
|
50
51
|
return 9, "aborted command"
|
51
52
|
end
|
52
53
|
Morpheus::Cli::Shell.instance.flush_history
|
data/lib/morpheus/cli/shell.rb
CHANGED
@@ -723,8 +723,8 @@ class Morpheus::Cli::Shell
|
|
723
723
|
# @return Hash like {:commands => [], :command_count => total}
|
724
724
|
def load_history_commands(options={})
|
725
725
|
phrase = options[:phrase]
|
726
|
-
|
727
|
-
|
726
|
+
sort_key = options[:sort] ? options[:sort].to_sym : nil
|
727
|
+
|
728
728
|
offset = options[:offset].to_i > 0 ? options[:offset].to_i : 0
|
729
729
|
max = options[:max].to_i > 0 ? options[:max].to_i : 25
|
730
730
|
|
@@ -739,15 +739,15 @@ class Morpheus::Cli::Shell
|
|
739
739
|
|
740
740
|
# sort is a bit different for this command, the default sort is by number
|
741
741
|
# it sorts oldest -> newest, but shows the very last page by default.
|
742
|
-
|
743
|
-
|
744
|
-
sort_key = :command
|
742
|
+
if options[:sort] && ![:number, :command].include?(options[:sort])
|
743
|
+
options[:sort] = nil
|
745
744
|
end
|
746
745
|
|
747
|
-
|
746
|
+
|
747
|
+
if options[:phrase] || sort_key || options[:direction] || options[:offset]
|
748
748
|
# this could be a large object...need to index our shell_history file lol
|
749
749
|
history_records = @history.keys.collect { |k| {number: k, command: @history[k]} }
|
750
|
-
if direction == 'desc'
|
750
|
+
if options[:direction] == 'desc'
|
751
751
|
history_records = history_records.sort {|x,y| y[sort_key] <=> x[sort_key] }
|
752
752
|
else
|
753
753
|
history_records = history_records.sort {|x,y| x[sort_key] <=> y[sort_key] }
|
@@ -756,26 +756,20 @@ class Morpheus::Cli::Shell
|
|
756
756
|
history_records = history_records.select {|it| it[:command].include?(phrase) || it[:number].to_s == phrase }
|
757
757
|
end
|
758
758
|
command_count = history_records.size
|
759
|
-
history_records = history_records[offset..max-1]
|
759
|
+
history_records = history_records[offset..(max-1)]
|
760
760
|
else
|
761
761
|
# default should try to be as fast as possible..
|
762
762
|
# no searching or sorting, default order by :number works
|
763
|
-
|
764
|
-
|
765
|
-
cmd_numbers = []
|
766
|
-
if direction == 'desc'
|
767
|
-
cmd_numbers = @history.keys[offset..(offset + max-1)]
|
763
|
+
if offset != 0
|
764
|
+
cmd_numbers = @history.keys.last(max + offset).first(max)
|
768
765
|
else
|
769
|
-
|
770
|
-
cmd_numbers = @history.keys.last(max + offset).first(max)
|
771
|
-
else
|
772
|
-
cmd_numbers = @history.keys.last(max)
|
773
|
-
end
|
774
|
-
history_records = cmd_numbers.collect { |k| {number: k, command: @history[k]} }
|
775
|
-
command_count = @history.size
|
766
|
+
cmd_numbers = @history.keys.last(max)
|
776
767
|
end
|
768
|
+
history_records = cmd_numbers.collect { |k| {number: k, command: @history[k]} }
|
769
|
+
command_count = @history.size
|
777
770
|
end
|
778
|
-
|
771
|
+
meta = {size:history_records.size, total:command_count.to_i, max:max, offset:offset}
|
772
|
+
return {:commands => history_records, :command_count => command_count, :meta => meta}
|
779
773
|
end
|
780
774
|
|
781
775
|
def print_history(options={})
|
@@ -794,7 +788,12 @@ class Morpheus::Cli::Shell
|
|
794
788
|
puts "#{history_record[:number].to_s.rjust(3, ' ')} #{history_record[:command]}"
|
795
789
|
end
|
796
790
|
if options[:show_pagination]
|
797
|
-
|
791
|
+
if options[:phrase] || options[:sort] || options[:direction] || options[:offset]
|
792
|
+
print_results_pagination({:meta => history_result[:meta]})
|
793
|
+
else
|
794
|
+
# default order is weird, it's the last page of results, 1-25 is misleading and showing the indexes is stranger
|
795
|
+
print_results_pagination({:meta => history_result[:meta]}, {:message =>"Viewing most recent %{size} of %{total} %{label}"})
|
796
|
+
end
|
798
797
|
print reset, "\n"
|
799
798
|
end
|
800
799
|
end
|
@@ -816,7 +815,7 @@ class Morpheus::Cli::Shell
|
|
816
815
|
@history = {}
|
817
816
|
@last_command_number = 0
|
818
817
|
@history_logger = load_history_logger
|
819
|
-
print
|
818
|
+
print green, "Command history flushed", reset, "\n"
|
820
819
|
return 0
|
821
820
|
end
|
822
821
|
end
|
data/lib/morpheus/cli/version.rb
CHANGED
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.
|
4
|
+
version: 3.6.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Estes
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2019-02-
|
14
|
+
date: 2019-02-28 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bundler
|