cobra_commander 0.13.0 → 0.14.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/CHANGELOG.md +6 -0
- data/lib/cobra_commander/cli/filters.rb +12 -1
- data/lib/cobra_commander/output/interactive_printer.rb +12 -7
- data/lib/cobra_commander/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: d3e2348a3ed7ceecd361b13fe0632bb5daa54a59652d4dd9eac5646c2ccc5878
|
4
|
+
data.tar.gz: 49dc4f2937e87a8146c685d82d7d45fea82dd16e3e0b880ef9944c8ac0710b0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ca9041bfb43cbec99252e00f52e117d8e2f09778afc686f1b204c4ff2e5733841f10b727adc3e3c9f28b121d61dff6ef4c79745a9e7574eb9bc36c3dd6ee5a9
|
7
|
+
data.tar.gz: befffb97f5743fce5066db00f5c434053bdebc275c12b74d95c3d33a375b8c9e6bf5e10fa186188a163f1f9c8fd91f01055d56c8880ee40815915878077aebc9
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,12 @@
|
|
2
2
|
|
3
3
|
## Unreleased
|
4
4
|
|
5
|
+
## Version 0.14.0 - 2021-11-24
|
6
|
+
|
7
|
+
* Retain selection on Interactive Printer [#69](https://github.com/powerhome/cobra_commander/pull/69)
|
8
|
+
* Sorts the interactive UI alphabetically with failures first [#68](https://github.com/powerhome/cobra_commander/pull/68)
|
9
|
+
* Switch from Rubocop to Standardrb [#67](https://github.com/powerhome/cobra_commander/pull/67)
|
10
|
+
|
5
11
|
## Version 0.13.0 - 2021-10-21
|
6
12
|
|
7
13
|
* Sorts the interactive UI alphabetically with failures first [#66](https://github.com/powerhome/cobra_commander/pull/66)
|
@@ -14,7 +14,18 @@ module CobraCommander
|
|
14
14
|
def find_component(name)
|
15
15
|
return umbrella.root unless name
|
16
16
|
|
17
|
-
umbrella.find(name) || error("Component #{name} not found,
|
17
|
+
umbrella.find(name) || error("Component #{name} not found, maybe #{suggestion(name)}") || exit(1)
|
18
|
+
end
|
19
|
+
|
20
|
+
def suggestion(name)
|
21
|
+
[*suggestions(name), 'one of "cobra ls"'].join(", ")
|
22
|
+
end
|
23
|
+
|
24
|
+
def suggestions(name)
|
25
|
+
spell_checker = DidYouMean::SpellChecker.new(dictionary: umbrella.components.map(&:name))
|
26
|
+
spell_checker.correct(name)
|
27
|
+
rescue NameError
|
28
|
+
[]
|
18
29
|
end
|
19
30
|
|
20
31
|
def components_filtered(component_name)
|
@@ -18,17 +18,14 @@ module CobraCommander
|
|
18
18
|
|
19
19
|
def initialize(contexts)
|
20
20
|
@prompt = TTY::Prompt.new
|
21
|
-
@options = contexts
|
22
|
-
.reduce({}) do |options, context|
|
23
|
-
template = context.success? ? SUCCESS : ERROR
|
24
|
-
options.merge format(template, context.component_name) => context
|
25
|
-
end
|
21
|
+
@options = map_options(contexts)
|
26
22
|
end
|
27
23
|
|
28
24
|
def run(output)
|
25
|
+
selected_context = nil
|
29
26
|
loop do
|
30
|
-
|
31
|
-
output.puts
|
27
|
+
selected_context = @prompt.select("Print output?", @options, default: @options.key(selected_context))
|
28
|
+
output.puts selected_context.output
|
32
29
|
end
|
33
30
|
rescue TTY::Reader::InputInterrupt
|
34
31
|
output.puts BYE
|
@@ -36,6 +33,14 @@ module CobraCommander
|
|
36
33
|
|
37
34
|
private
|
38
35
|
|
36
|
+
def map_options(contexts)
|
37
|
+
contexts.sort(&method(:sort_contexts))
|
38
|
+
.reduce({}) do |options, context|
|
39
|
+
template = context.success? ? SUCCESS : ERROR
|
40
|
+
options.merge format(template, context.component_name) => context
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
39
44
|
def sort_contexts(context_a, context_b)
|
40
45
|
if context_a.success? == context_b.success?
|
41
46
|
context_a.component_name <=> context_b.component_name
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cobra_commander
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Langfeld
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2021-
|
13
|
+
date: 2021-11-24 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|