abt-cli 0.0.24 → 0.0.25

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: 6b21c8f210a7c29d5f43ef7c756cfdcc7d8ef2b13ef4dcaef1cec4f8bf2297a1
4
- data.tar.gz: f7586aa063494d796ded7c2e8696d9bf834e24be3004c621408e2fdd58f9b516
3
+ metadata.gz: 3af480b982ad0feef367f157d2658f5dd7a3059de13f7098ff267fd06b53fd47
4
+ data.tar.gz: 15b6177165d60fa0bc76c0ac201755d9fb987c62b98e97784ebd2eb5748f12bf
5
5
  SHA512:
6
- metadata.gz: b9d5278daeec2067937212108eb0ba478c1ec80d45c14a94025f7d6d83c5a30c4cdb716d010a4dfc807166165cd04af8e7962ec2b776f9f2fb7feee7edb65194
7
- data.tar.gz: 2faba55f9dcf4ee66f82a77b647fe367fbebeb74c70fde23edd6543ad83ce1f995bdeb01673555219c498a971919e0b2fd0ec1f8362484f56ba6a54a2b65503c
6
+ metadata.gz: 9eb5c49b996574004c1abffffad6aef76e3bc8ad7ea3fcbf0e05e2b0b33788d01cd041e031f5e98c85b86b7aee442ce8b2ac11995944a1e8d8674053736a6f9b
7
+ data.tar.gz: 16278e95b9d5e25a7b2fb7dc931e140b732638ce767e99b20a9b7b442a560b6e56abf982f42a65b7dd97973d58332854915421d26cac686a8af8965a0dcaa148
@@ -14,17 +14,20 @@ module Abt
14
14
  Abt::Helpers.read_user_input
15
15
  end
16
16
 
17
- def boolean(text)
18
- output.puts text
17
+ def boolean(text, default: nil)
18
+ choices = [default == true ? "Y" : "y",
19
+ default == false ? "N" : "n"].join("/")
19
20
 
20
- loop do
21
- output.print("(y / n): ")
21
+ output.print("#{text} (#{choices}): ")
22
22
 
23
- case Abt::Helpers.read_user_input
24
- when "y", "Y" then return true
25
- when "n", "N" then return false
26
- else output.puts "Invalid choice" end
27
- end
23
+ input = Abt::Helpers.read_user_input.downcase
24
+
25
+ return true if input == "y"
26
+ return false if input == "n"
27
+ return default if input.empty? && !default.nil?
28
+
29
+ output.puts "Invalid choice"
30
+ boolean(text, default: default)
28
31
  end
29
32
 
30
33
  def choice(text, options, nil_option: false)
@@ -53,10 +53,22 @@ module Abt
53
53
  warn("Section is empty")
54
54
  select_work_item
55
55
  else
56
- cli.prompt.choice("Select a work item", work_items, nil_option: true) || select_work_item
56
+ prompt_work_item(work_items) || select_work_item
57
57
  end
58
58
  end
59
59
 
60
+ def prompt_work_item(work_items)
61
+ options = work_items.map do |work_item|
62
+ {
63
+ "id" => work_item["id"],
64
+ "name" => "##{work_item['id']} #{work_item['name']}"
65
+ }
66
+ end
67
+
68
+ choice = cli.prompt.choice("Select a work item", options, nil_option: true)
69
+ choice && work_items.find { |work_item| work_item["id"] == choice["id"] }
70
+ end
71
+
60
72
  def work_items_in_column(column)
61
73
  work_items = api.work_item_query(
62
74
  <<~WIQL
@@ -30,7 +30,7 @@ module Abt
30
30
 
31
31
  def create_and_switch
32
32
  warn("No such branch: #{branch_name}")
33
- abort("Aborting") unless cli.prompt.boolean("Create branch?")
33
+ abort("Aborting") unless cli.prompt.boolean("Create branch?", default: true)
34
34
 
35
35
  Open3.popen3("git switch -c #{branch_name}") do |_i, _o, _e, thread|
36
36
  thread.value
data/lib/abt/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Abt
4
- VERSION = "0.0.24"
4
+ VERSION = "0.0.25"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: abt-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.24
4
+ version: 0.0.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jesper Sørensen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-15 00:00:00.000000000 Z
11
+ date: 2021-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-inflector