cobra_commander 0.13.0 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4eb007805f5f11954ed14e349409c7486fc6b52d0a041f8066c75c47f8d045b8
4
- data.tar.gz: 68ac383fb087d118a276e5aed0199b51fd09b05c110d7ff4539f18097b1ea367
3
+ metadata.gz: d3e2348a3ed7ceecd361b13fe0632bb5daa54a59652d4dd9eac5646c2ccc5878
4
+ data.tar.gz: 49dc4f2937e87a8146c685d82d7d45fea82dd16e3e0b880ef9944c8ac0710b0c
5
5
  SHA512:
6
- metadata.gz: 6a5f69e411bf49bd1de717934f27c0d364378e07ce1728855b2783de0c73dff791be433565b689656d4481b2ad294086fc43118beafc16ca445a2c91ea7916c9
7
- data.tar.gz: afdf327649c953bc155f5e01a6db9f4cef12ed625f7c791534e7ae65ac0d05c2260bfd20b03f382eac9aaee9f2e84612806c050327491c2f806223d7e612aa67
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, try one of `cobra ls`") || exit(1)
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.sort(&method(:sort_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
- context = @prompt.select("Print output?", @options)
31
- output.puts context.output
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CobraCommander
4
- VERSION = "0.13.0"
4
+ VERSION = "0.14.0"
5
5
  end
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.13.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-10-21 00:00:00.000000000 Z
13
+ date: 2021-11-24 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler