cli-ui 1.1.0 → 1.1.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/README.md +1 -1
- data/lib/cli/ui/progress.rb +2 -2
- data/lib/cli/ui/prompt/interactive_options.rb +6 -1
- data/lib/cli/ui/stdout_router.rb +9 -7
- data/lib/cli/ui/terminal.rb +6 -3
- data/lib/cli/ui/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e859c2ecb4ac2b2b43b843c664284e8ee95e7a43
|
4
|
+
data.tar.gz: 102c74d7762e602e87fafba4eee93ba85f8e20cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59ff9f79be424133981a6eb878b3a7b8818c200a9f24f545f9c036765dcd9b0bd13a4b313121bc603282b2aeeb9dc516ac0d788fac44c5e50888cd6f8c566e50
|
7
|
+
data.tar.gz: b9a1b36d13f0c9779f481e18cbabfbd42e62735e5de9705005bc3affaaffa2113be8aa3c1804d154352c2a699da13e17217e7fb1947cd9e55fe8d69fafba4857
|
data/README.md
CHANGED
@@ -52,7 +52,7 @@ CLI::UI.ask('What language/framework do you use?', options: %w(rails go ruby pyt
|
|
52
52
|
Can also assign callbacks to each option
|
53
53
|
|
54
54
|
```ruby
|
55
|
-
CLI::UI.ask('What language/framework do you use?') do |handler|
|
55
|
+
CLI::UI::Prompt.ask('What language/framework do you use?') do |handler|
|
56
56
|
handler.option('rails') { |selection| selection }
|
57
57
|
handler.option('go') { |selection| selection }
|
58
58
|
handler.option('ruby') { |selection| selection }
|
data/lib/cli/ui/progress.rb
CHANGED
@@ -76,8 +76,8 @@ module CLI
|
|
76
76
|
def to_s
|
77
77
|
suffix = " #{(@percent_done * 100).round(2)}%"
|
78
78
|
workable_width = @max_width - Frame.prefix_width - suffix.size
|
79
|
-
filled = (@percent_done * workable_width.to_f).ceil
|
80
|
-
unfilled = workable_width - filled
|
79
|
+
filled = [(@percent_done * workable_width.to_f).ceil, 0].max
|
80
|
+
unfilled = [workable_width - filled, 0].max
|
81
81
|
|
82
82
|
CLI::UI.resolve_text [
|
83
83
|
FILLED_BAR + ' ' * filled,
|
@@ -76,8 +76,13 @@ module CLI
|
|
76
76
|
def num_lines
|
77
77
|
# @options will be an array of questions but each option can be multi-line
|
78
78
|
# so to get the # of lines, you need to join then split
|
79
|
+
|
80
|
+
# empty_option_count is needed since empty option titles are omitted
|
81
|
+
# from the line count when reject(&:empty?) is called
|
82
|
+
|
83
|
+
empty_option_count = @options.count(&:empty?)
|
79
84
|
joined_options = @options.join("\n")
|
80
|
-
joined_options.split("\n").reject(&:empty?).size
|
85
|
+
joined_options.split("\n").reject(&:empty?).size + empty_option_count
|
81
86
|
end
|
82
87
|
|
83
88
|
ESC = "\e"
|
data/lib/cli/ui/stdout_router.rb
CHANGED
@@ -15,13 +15,15 @@ module CLI
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def write(*args)
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
18
|
+
args = args.map do |str|
|
19
|
+
if auto_frame_inset?
|
20
|
+
str = str.dup # unfreeze
|
21
|
+
str = str.force_encoding(Encoding::UTF_8)
|
22
|
+
apply_line_prefix(str, CLI::UI::Frame.prefix)
|
23
|
+
else
|
24
|
+
@pending_newline = false
|
25
|
+
str
|
26
|
+
end
|
25
27
|
end
|
26
28
|
|
27
29
|
hook = Thread.current[:cliui_output_hook]
|
data/lib/cli/ui/terminal.rb
CHANGED
@@ -4,17 +4,20 @@ require 'io/console'
|
|
4
4
|
module CLI
|
5
5
|
module UI
|
6
6
|
module Terminal
|
7
|
+
DEFAULT_WIDTH = 80
|
8
|
+
|
7
9
|
# Returns the width of the terminal, if possible
|
8
10
|
# Otherwise will return 80
|
9
11
|
#
|
10
12
|
def self.width
|
11
13
|
if console = IO.respond_to?(:console) && IO.console
|
12
|
-
console.winsize[1]
|
14
|
+
width = console.winsize[1]
|
15
|
+
width.zero? ? DEFAULT_WIDTH : width
|
13
16
|
else
|
14
|
-
|
17
|
+
DEFAULT_WIDTH
|
15
18
|
end
|
16
19
|
rescue Errno::EIO
|
17
|
-
|
20
|
+
DEFAULT_WIDTH
|
18
21
|
end
|
19
22
|
end
|
20
23
|
end
|
data/lib/cli/ui/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cli-ui
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Burke Libbey
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2018-
|
13
|
+
date: 2018-04-09 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|