cli-ui 2.3.0 → 2.3.1
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/cli/ui/prompt/interactive_options.rb +20 -0
- data/lib/cli/ui/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99ed2ae4a35b13db165864297acf7cfc4e636283e51683a7954ca2e2f43ac94c
|
4
|
+
data.tar.gz: 30eb1a74cdbd50b95d9c48209c97258261970c9678eb71e089bb894a018bcb0b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 219e73a9baa10649b9cd14280ce9fe8d2f18a614006c9b4f5c8c79b3df3da3ef236c00ec290816ab866ff3d67cf058ecf5c88f0034e331a1ab77cdef1df25111
|
7
|
+
data.tar.gz: 79de546a04f2ca9fe49246be7df31582cafc791799bbacd868af7fa1e381e42a462685e619a734745500203a25587a7eb6eaee04465b269cee8242ad67334a1b
|
@@ -230,6 +230,12 @@ module CLI
|
|
230
230
|
end
|
231
231
|
elsif n == 0
|
232
232
|
# Ignore pressing "0" when not in multiple mode
|
233
|
+
elsif should_enter_select_mode?(n)
|
234
|
+
# When we have more than 9 options, we need to enter select mode
|
235
|
+
# to avoid pre-selecting (e.g) 1 when the user wanted 10.
|
236
|
+
# This also applies to 2 and 20+ options, 3/30+, etc.
|
237
|
+
start_line_select
|
238
|
+
@active = n
|
233
239
|
else
|
234
240
|
@active = n
|
235
241
|
@answer = n
|
@@ -237,6 +243,20 @@ module CLI
|
|
237
243
|
@redraw = true
|
238
244
|
end
|
239
245
|
|
246
|
+
sig { params(n: Integer).returns(T::Boolean) }
|
247
|
+
def should_enter_select_mode?(n)
|
248
|
+
# If we have less than 10 options, we don't need to enter select mode
|
249
|
+
# and we can just select the option directly. This just keeps the code easier
|
250
|
+
# by making the cases simpler to understand
|
251
|
+
return false if @options.length <= 9
|
252
|
+
|
253
|
+
# At this point we have 10+ options so always need to check if we should run.
|
254
|
+
# This can be simplified to checking if the length of options is >= to the option selected * 10:
|
255
|
+
# n == 1 && options.length >= 10 (1 * 10), n == 2 && options.length >= 20 (2 * 10), etc.
|
256
|
+
# which can be further simplified to just:
|
257
|
+
@options.length >= (n * 10)
|
258
|
+
end
|
259
|
+
|
240
260
|
sig { params(char: String).void }
|
241
261
|
def select_bool(char)
|
242
262
|
return unless (@options - ['yes', 'no']).empty?
|
data/lib/cli/ui/version.rb
CHANGED
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cli-ui
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Burke Libbey
|
8
8
|
- Julian Nadeau
|
9
9
|
- Lisa Ugray
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2025-03-17 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: minitest
|
@@ -86,7 +86,7 @@ homepage: https://github.com/shopify/cli-ui
|
|
86
86
|
licenses:
|
87
87
|
- MIT
|
88
88
|
metadata: {}
|
89
|
-
post_install_message:
|
89
|
+
post_install_message:
|
90
90
|
rdoc_options: []
|
91
91
|
require_paths:
|
92
92
|
- lib
|
@@ -101,8 +101,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
101
|
- !ruby/object:Gem::Version
|
102
102
|
version: '0'
|
103
103
|
requirements: []
|
104
|
-
rubygems_version: 3.
|
105
|
-
signing_key:
|
104
|
+
rubygems_version: 3.5.9
|
105
|
+
signing_key:
|
106
106
|
specification_version: 4
|
107
107
|
summary: Terminal UI framework
|
108
108
|
test_files: []
|