cli-ui 1.2.1 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.dependabot/config.yml +8 -0
- data/.github/CODEOWNERS +1 -0
- data/.github/probots.yml +2 -0
- data/.gitignore +0 -1
- data/.rubocop.yml +28 -4
- data/.travis.yml +5 -3
- data/Gemfile +3 -2
- data/Gemfile.lock +60 -0
- data/README.md +50 -3
- data/Rakefile +2 -2
- data/bin/console +3 -3
- data/cli-ui.gemspec +13 -13
- data/dev.yml +1 -1
- data/lib/cli/ui.rb +77 -31
- data/lib/cli/ui/ansi.rb +10 -6
- data/lib/cli/ui/color.rb +12 -7
- data/lib/cli/ui/formatter.rb +34 -21
- data/lib/cli/ui/frame.rb +111 -152
- data/lib/cli/ui/frame/frame_stack.rb +98 -0
- data/lib/cli/ui/frame/frame_style.rb +120 -0
- data/lib/cli/ui/frame/frame_style/box.rb +166 -0
- data/lib/cli/ui/frame/frame_style/bracket.rb +139 -0
- data/lib/cli/ui/glyph.rb +23 -17
- data/lib/cli/ui/os.rb +67 -0
- data/lib/cli/ui/printer.rb +59 -0
- data/lib/cli/ui/progress.rb +10 -8
- data/lib/cli/ui/prompt.rb +107 -21
- data/lib/cli/ui/prompt/interactive_options.rb +271 -67
- data/lib/cli/ui/prompt/options_handler.rb +7 -2
- data/lib/cli/ui/spinner.rb +23 -5
- data/lib/cli/ui/spinner/spin_group.rb +41 -13
- data/lib/cli/ui/stdout_router.rb +13 -8
- data/lib/cli/ui/terminal.rb +26 -16
- data/lib/cli/ui/truncater.rb +4 -4
- data/lib/cli/ui/version.rb +1 -1
- data/lib/cli/ui/widgets.rb +77 -0
- data/lib/cli/ui/widgets/base.rb +27 -0
- data/lib/cli/ui/widgets/status.rb +61 -0
- data/lib/cli/ui/wrap.rb +56 -0
- metadata +22 -24
- data/lib/cli/ui/box.rb +0 -15
data/lib/cli/ui/wrap.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require 'cli/ui'
|
3
|
+
require 'cli/ui/frame/frame_stack'
|
4
|
+
require 'cli/ui/frame/frame_style'
|
5
|
+
|
6
|
+
module CLI
|
7
|
+
module UI
|
8
|
+
class Wrap
|
9
|
+
def initialize(input)
|
10
|
+
@input = input
|
11
|
+
end
|
12
|
+
|
13
|
+
def wrap
|
14
|
+
max_width = Terminal.width - Frame.prefix_width
|
15
|
+
width = 0
|
16
|
+
final = []
|
17
|
+
# Create an alternation of format codes of parameter lengths 1-20, since + and {1,n} not allowed in lookbehind
|
18
|
+
format_codes = (1..20).map { |n| /\x1b\[[\d;]{#{n}}m/ }.join('|')
|
19
|
+
codes = ''
|
20
|
+
@input.split(/(?=\s|\x1b\[[\d;]+m|\r)|(?<=\s|#{format_codes})/).each do |token|
|
21
|
+
case token
|
22
|
+
when '\x1B[0?m'
|
23
|
+
codes = ''
|
24
|
+
final << token
|
25
|
+
when /\x1b\[[\d;]+m/
|
26
|
+
codes += token # Track in use format codes so that they are resent after frame coloring
|
27
|
+
final << token
|
28
|
+
when "\n"
|
29
|
+
final << "\n#{codes}"
|
30
|
+
width = 0
|
31
|
+
when /\s/
|
32
|
+
token_width = ANSI.printing_width(token)
|
33
|
+
if width + token_width <= max_width
|
34
|
+
final << token
|
35
|
+
width += token_width
|
36
|
+
else
|
37
|
+
final << "\n#{codes}"
|
38
|
+
width = 0
|
39
|
+
end
|
40
|
+
else
|
41
|
+
token_width = ANSI.printing_width(token)
|
42
|
+
if width + token_width <= max_width
|
43
|
+
final << token
|
44
|
+
width += token_width
|
45
|
+
else
|
46
|
+
final << "\n#{codes}"
|
47
|
+
final << token
|
48
|
+
width = token_width
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
final.join
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
metadata
CHANGED
@@ -1,45 +1,31 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cli-ui
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
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: 2021-04-14 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
|
-
- !ruby/object:Gem::Dependency
|
16
|
-
name: bundler
|
17
|
-
requirement: !ruby/object:Gem::Requirement
|
18
|
-
requirements:
|
19
|
-
- - "~>"
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: '1.15'
|
22
|
-
type: :development
|
23
|
-
prerelease: false
|
24
|
-
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
requirements:
|
26
|
-
- - "~>"
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
version: '1.15'
|
29
15
|
- !ruby/object:Gem::Dependency
|
30
16
|
name: rake
|
31
17
|
requirement: !ruby/object:Gem::Requirement
|
32
18
|
requirements:
|
33
19
|
- - "~>"
|
34
20
|
- !ruby/object:Gem::Version
|
35
|
-
version: '
|
21
|
+
version: '13.0'
|
36
22
|
type: :development
|
37
23
|
prerelease: false
|
38
24
|
version_requirements: !ruby/object:Gem::Requirement
|
39
25
|
requirements:
|
40
26
|
- - "~>"
|
41
27
|
- !ruby/object:Gem::Version
|
42
|
-
version: '
|
28
|
+
version: '13.0'
|
43
29
|
- !ruby/object:Gem::Dependency
|
44
30
|
name: minitest
|
45
31
|
requirement: !ruby/object:Gem::Requirement
|
@@ -63,10 +49,14 @@ executables: []
|
|
63
49
|
extensions: []
|
64
50
|
extra_rdoc_files: []
|
65
51
|
files:
|
52
|
+
- ".dependabot/config.yml"
|
53
|
+
- ".github/CODEOWNERS"
|
54
|
+
- ".github/probots.yml"
|
66
55
|
- ".gitignore"
|
67
56
|
- ".rubocop.yml"
|
68
57
|
- ".travis.yml"
|
69
58
|
- Gemfile
|
59
|
+
- Gemfile.lock
|
70
60
|
- LICENSE.txt
|
71
61
|
- README.md
|
72
62
|
- Rakefile
|
@@ -75,11 +65,16 @@ files:
|
|
75
65
|
- dev.yml
|
76
66
|
- lib/cli/ui.rb
|
77
67
|
- lib/cli/ui/ansi.rb
|
78
|
-
- lib/cli/ui/box.rb
|
79
68
|
- lib/cli/ui/color.rb
|
80
69
|
- lib/cli/ui/formatter.rb
|
81
70
|
- lib/cli/ui/frame.rb
|
71
|
+
- lib/cli/ui/frame/frame_stack.rb
|
72
|
+
- lib/cli/ui/frame/frame_style.rb
|
73
|
+
- lib/cli/ui/frame/frame_style/box.rb
|
74
|
+
- lib/cli/ui/frame/frame_style/bracket.rb
|
82
75
|
- lib/cli/ui/glyph.rb
|
76
|
+
- lib/cli/ui/os.rb
|
77
|
+
- lib/cli/ui/printer.rb
|
83
78
|
- lib/cli/ui/progress.rb
|
84
79
|
- lib/cli/ui/prompt.rb
|
85
80
|
- lib/cli/ui/prompt/interactive_options.rb
|
@@ -91,11 +86,15 @@ files:
|
|
91
86
|
- lib/cli/ui/terminal.rb
|
92
87
|
- lib/cli/ui/truncater.rb
|
93
88
|
- lib/cli/ui/version.rb
|
89
|
+
- lib/cli/ui/widgets.rb
|
90
|
+
- lib/cli/ui/widgets/base.rb
|
91
|
+
- lib/cli/ui/widgets/status.rb
|
92
|
+
- lib/cli/ui/wrap.rb
|
94
93
|
homepage: https://github.com/shopify/cli-ui
|
95
94
|
licenses:
|
96
95
|
- MIT
|
97
96
|
metadata: {}
|
98
|
-
post_install_message:
|
97
|
+
post_install_message:
|
99
98
|
rdoc_options: []
|
100
99
|
require_paths:
|
101
100
|
- lib
|
@@ -110,9 +109,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
109
|
- !ruby/object:Gem::Version
|
111
110
|
version: '0'
|
112
111
|
requirements: []
|
113
|
-
|
114
|
-
|
115
|
-
signing_key:
|
112
|
+
rubygems_version: 3.0.2
|
113
|
+
signing_key:
|
116
114
|
specification_version: 4
|
117
115
|
summary: Terminal UI framework
|
118
116
|
test_files: []
|