cli-ui 1.2.2 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +45 -1
- data/lib/cli/ui.rb +75 -29
- 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 +9 -7
- data/lib/cli/ui/prompt.rb +97 -21
- data/lib/cli/ui/prompt/interactive_options.rb +75 -61
- 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 +34 -12
- 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 +17 -16
- data/.gitignore +0 -15
- data/.rubocop.yml +0 -17
- data/.travis.yml +0 -5
- data/Gemfile +0 -16
- data/Rakefile +0 -20
- data/bin/console +0 -14
- data/cli-ui.gemspec +0 -27
- data/dev.yml +0 -14
- 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,16 +1,16 @@
|
|
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.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: 2021-04-15 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rake
|
@@ -18,14 +18,14 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - "~>"
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '
|
21
|
+
version: '13.0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
26
|
- - "~>"
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version: '
|
28
|
+
version: '13.0'
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: minitest
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
@@ -49,23 +49,20 @@ executables: []
|
|
49
49
|
extensions: []
|
50
50
|
extra_rdoc_files: []
|
51
51
|
files:
|
52
|
-
- ".gitignore"
|
53
|
-
- ".rubocop.yml"
|
54
|
-
- ".travis.yml"
|
55
|
-
- Gemfile
|
56
52
|
- LICENSE.txt
|
57
53
|
- README.md
|
58
|
-
- Rakefile
|
59
|
-
- bin/console
|
60
|
-
- cli-ui.gemspec
|
61
|
-
- dev.yml
|
62
54
|
- lib/cli/ui.rb
|
63
55
|
- lib/cli/ui/ansi.rb
|
64
|
-
- lib/cli/ui/box.rb
|
65
56
|
- lib/cli/ui/color.rb
|
66
57
|
- lib/cli/ui/formatter.rb
|
67
58
|
- lib/cli/ui/frame.rb
|
59
|
+
- lib/cli/ui/frame/frame_stack.rb
|
60
|
+
- lib/cli/ui/frame/frame_style.rb
|
61
|
+
- lib/cli/ui/frame/frame_style/box.rb
|
62
|
+
- lib/cli/ui/frame/frame_style/bracket.rb
|
68
63
|
- lib/cli/ui/glyph.rb
|
64
|
+
- lib/cli/ui/os.rb
|
65
|
+
- lib/cli/ui/printer.rb
|
69
66
|
- lib/cli/ui/progress.rb
|
70
67
|
- lib/cli/ui/prompt.rb
|
71
68
|
- lib/cli/ui/prompt/interactive_options.rb
|
@@ -77,11 +74,15 @@ files:
|
|
77
74
|
- lib/cli/ui/terminal.rb
|
78
75
|
- lib/cli/ui/truncater.rb
|
79
76
|
- lib/cli/ui/version.rb
|
77
|
+
- lib/cli/ui/widgets.rb
|
78
|
+
- lib/cli/ui/widgets/base.rb
|
79
|
+
- lib/cli/ui/widgets/status.rb
|
80
|
+
- lib/cli/ui/wrap.rb
|
80
81
|
homepage: https://github.com/shopify/cli-ui
|
81
82
|
licenses:
|
82
83
|
- MIT
|
83
84
|
metadata: {}
|
84
|
-
post_install_message:
|
85
|
+
post_install_message:
|
85
86
|
rdoc_options: []
|
86
87
|
require_paths:
|
87
88
|
- lib
|
@@ -97,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
97
98
|
version: '0'
|
98
99
|
requirements: []
|
99
100
|
rubygems_version: 3.0.2
|
100
|
-
signing_key:
|
101
|
+
signing_key:
|
101
102
|
specification_version: 4
|
102
103
|
summary: Terminal UI framework
|
103
104
|
test_files: []
|
data/.gitignore
DELETED
data/.rubocop.yml
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
inherit_from:
|
2
|
-
- http://shopify.github.io/ruby-style-guide/rubocop.yml
|
3
|
-
|
4
|
-
AllCops:
|
5
|
-
TargetRubyVersion: 2.1
|
6
|
-
|
7
|
-
# This doesn't take into account retrying from an exception
|
8
|
-
Lint/HandleExceptions:
|
9
|
-
Enabled: false
|
10
|
-
|
11
|
-
# allow String.new to create mutable strings
|
12
|
-
Style/EmptyLiteral:
|
13
|
-
Enabled: false
|
14
|
-
|
15
|
-
# allow the use of globals which makes sense in a CLI app like this
|
16
|
-
Style/GlobalVars:
|
17
|
-
Enabled: false
|
data/.travis.yml
DELETED
data/Gemfile
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
# NOTE: These are development-only dependencies
|
2
|
-
source "https://rubygems.org"
|
3
|
-
|
4
|
-
gemspec
|
5
|
-
|
6
|
-
group :development, :test do
|
7
|
-
gem 'rubocop'
|
8
|
-
gem 'byebug'
|
9
|
-
gem 'method_source'
|
10
|
-
end
|
11
|
-
|
12
|
-
group :test do
|
13
|
-
gem 'mocha', require: false
|
14
|
-
gem 'minitest', '>= 5.0.0', require: false
|
15
|
-
gem 'minitest-reporters', require: false
|
16
|
-
end
|
data/Rakefile
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.expand_path('../lib', __FILE__))
|
2
|
-
require 'cli/ui'
|
3
|
-
require 'rake/testtask'
|
4
|
-
require 'rubocop/rake_task'
|
5
|
-
require 'bundler/gem_tasks'
|
6
|
-
|
7
|
-
TEST_ROOT = File.expand_path('../test', __FILE__)
|
8
|
-
|
9
|
-
Rake::TestTask.new do |t|
|
10
|
-
t.libs += ["test"]
|
11
|
-
t.test_files = FileList[File.join(TEST_ROOT, '**', '*_test.rb')]
|
12
|
-
t.verbose = false
|
13
|
-
t.warning = false
|
14
|
-
end
|
15
|
-
|
16
|
-
RuboCop::RakeTask.new(:style) do |t|
|
17
|
-
t.options = ['--display-cop-names']
|
18
|
-
end
|
19
|
-
|
20
|
-
task default: [:test]
|
data/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "cli/ui"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start(__FILE__)
|
data/cli-ui.gemspec
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path("../lib", __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require "cli/ui/version"
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "cli-ui"
|
8
|
-
spec.version = CLI::UI::VERSION
|
9
|
-
spec.authors = ["Burke Libbey", "Julian Nadeau", "Lisa Ugray"]
|
10
|
-
spec.email = ["burke.libbey@shopify.com", "julian.nadeau@shopify.com", "lisa.ugray@shopify.com"]
|
11
|
-
|
12
|
-
spec.summary = 'Terminal UI framework'
|
13
|
-
spec.description = 'Terminal UI framework'
|
14
|
-
spec.homepage = "https://github.com/shopify/cli-ui"
|
15
|
-
spec.license = "MIT"
|
16
|
-
|
17
|
-
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
-
f.match(%r{^(test|spec|features)/})
|
19
|
-
end
|
20
|
-
spec.bindir = "exe"
|
21
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
-
spec.require_paths = ["lib"]
|
23
|
-
|
24
|
-
# spec.add_development_dependency "bundler", "~> 2.0"
|
25
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
-
spec.add_development_dependency "minitest", "~> 5.0"
|
27
|
-
end
|
data/dev.yml
DELETED