rfix 2.0.4 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/rfix +11 -90
- data/lib/rfix.rb +10 -9
- data/lib/rfix/branch/reference.rb +2 -2
- data/lib/rfix/branch/upstream.rb +2 -4
- data/lib/rfix/cli/command.rb +14 -1
- data/lib/rfix/cli/command/all.rb +21 -0
- data/lib/rfix/cli/command/base.rb +30 -19
- data/lib/rfix/cli/command/branch.rb +2 -0
- data/lib/rfix/cli/command/help.rb +2 -0
- data/lib/rfix/cli/command/info.rb +6 -1
- data/lib/rfix/cli/command/local.rb +2 -0
- data/lib/rfix/cli/command/origin.rb +2 -0
- data/lib/rfix/cli/command/setup.rb +2 -0
- data/lib/rfix/cli/command/status.rb +39 -0
- data/lib/rfix/collector.rb +69 -0
- data/lib/rfix/diff.rb +69 -0
- data/lib/rfix/extension/comment_config.rb +15 -0
- data/lib/rfix/extension/offense.rb +17 -14
- data/lib/rfix/extension/pastel.rb +7 -4
- data/lib/rfix/extension/progresbar.rb +15 -0
- data/lib/rfix/extension/strings.rb +10 -2
- data/lib/rfix/file.rb +5 -3
- data/lib/rfix/file/base.rb +21 -14
- data/lib/rfix/file/deleted.rb +2 -0
- data/lib/rfix/file/ignored.rb +2 -0
- data/lib/rfix/file/null.rb +17 -0
- data/lib/rfix/file/tracked.rb +39 -23
- data/lib/rfix/file/undefined.rb +17 -0
- data/lib/rfix/file/untracked.rb +3 -1
- data/lib/rfix/formatter.rb +67 -71
- data/lib/rfix/highlighter.rb +1 -3
- data/lib/rfix/rake/gemfile.rb +26 -23
- data/lib/rfix/repository.rb +59 -96
- data/lib/rfix/types.rb +24 -14
- data/lib/rfix/version.rb +1 -1
- data/rfix.gemspec +11 -3
- data/vendor/cli-ui/Gemfile +17 -0
- data/vendor/cli-ui/Gemfile.lock +60 -0
- data/vendor/cli-ui/LICENSE.txt +21 -0
- data/vendor/cli-ui/README.md +224 -0
- data/vendor/cli-ui/Rakefile +20 -0
- data/vendor/cli-ui/bin/console +14 -0
- data/vendor/cli-ui/cli-ui.gemspec +25 -0
- data/vendor/cli-ui/dev.yml +14 -0
- data/vendor/cli-ui/lib/cli/ui.rb +233 -0
- data/vendor/cli-ui/lib/cli/ui/ansi.rb +157 -0
- data/vendor/cli-ui/lib/cli/ui/color.rb +84 -0
- data/vendor/cli-ui/lib/cli/ui/formatter.rb +192 -0
- data/vendor/cli-ui/lib/cli/ui/frame.rb +269 -0
- data/vendor/cli-ui/lib/cli/ui/frame/frame_stack.rb +98 -0
- data/vendor/cli-ui/lib/cli/ui/frame/frame_style.rb +120 -0
- data/vendor/cli-ui/lib/cli/ui/frame/frame_style/box.rb +166 -0
- data/vendor/cli-ui/lib/cli/ui/frame/frame_style/bracket.rb +139 -0
- data/vendor/cli-ui/lib/cli/ui/glyph.rb +84 -0
- data/vendor/cli-ui/lib/cli/ui/os.rb +67 -0
- data/vendor/cli-ui/lib/cli/ui/printer.rb +59 -0
- data/vendor/cli-ui/lib/cli/ui/progress.rb +90 -0
- data/vendor/cli-ui/lib/cli/ui/prompt.rb +297 -0
- data/vendor/cli-ui/lib/cli/ui/prompt/interactive_options.rb +484 -0
- data/vendor/cli-ui/lib/cli/ui/prompt/options_handler.rb +29 -0
- data/vendor/cli-ui/lib/cli/ui/spinner.rb +66 -0
- data/vendor/cli-ui/lib/cli/ui/spinner/async.rb +40 -0
- data/vendor/cli-ui/lib/cli/ui/spinner/spin_group.rb +263 -0
- data/vendor/cli-ui/lib/cli/ui/stdout_router.rb +232 -0
- data/vendor/cli-ui/lib/cli/ui/terminal.rb +46 -0
- data/vendor/cli-ui/lib/cli/ui/truncater.rb +102 -0
- data/vendor/cli-ui/lib/cli/ui/version.rb +5 -0
- data/vendor/cli-ui/lib/cli/ui/widgets.rb +77 -0
- data/vendor/cli-ui/lib/cli/ui/widgets/base.rb +27 -0
- data/vendor/cli-ui/lib/cli/ui/widgets/status.rb +61 -0
- data/vendor/cli-ui/lib/cli/ui/wrap.rb +56 -0
- data/vendor/cli-ui/test/cli/ui/ansi_test.rb +32 -0
- data/vendor/cli-ui/test/cli/ui/cli_ui_test.rb +23 -0
- data/vendor/cli-ui/test/cli/ui/color_test.rb +40 -0
- data/vendor/cli-ui/test/cli/ui/formatter_test.rb +79 -0
- data/vendor/cli-ui/test/cli/ui/glyph_test.rb +68 -0
- data/vendor/cli-ui/test/cli/ui/printer_test.rb +103 -0
- data/vendor/cli-ui/test/cli/ui/progress_test.rb +46 -0
- data/vendor/cli-ui/test/cli/ui/prompt/options_handler_test.rb +39 -0
- data/vendor/cli-ui/test/cli/ui/prompt_test.rb +348 -0
- data/vendor/cli-ui/test/cli/ui/spinner/spin_group_test.rb +39 -0
- data/vendor/cli-ui/test/cli/ui/spinner_test.rb +141 -0
- data/vendor/cli-ui/test/cli/ui/stdout_router_test.rb +32 -0
- data/vendor/cli-ui/test/cli/ui/terminal_test.rb +26 -0
- data/vendor/cli-ui/test/cli/ui/truncater_test.rb +31 -0
- data/vendor/cli-ui/test/cli/ui/widgets/status_test.rb +49 -0
- data/vendor/cli-ui/test/cli/ui/widgets_test.rb +15 -0
- data/vendor/cli-ui/test/test_helper.rb +53 -0
- data/vendor/cli-ui/tmp/cache/bootsnap/compile-cache/d9/c036af0f3dc494 +0 -0
- data/vendor/cli-ui/tmp/cache/bootsnap/load-path-cache +0 -0
- data/vendor/dry-cli/lib/dry/cli/command.rb +2 -1
- data/vendor/dry-cli/tmp/cache/bootsnap/compile-cache/ff/a22a5daafbd74c +0 -0
- data/vendor/dry-cli/tmp/cache/bootsnap/load-path-cache +0 -0
- data/vendor/strings-ansi/tmp/cache/bootsnap/compile-cache/79/49cf49407b370e +0 -0
- data/vendor/strings-ansi/tmp/cache/bootsnap/load-path-cache +0 -0
- metadata +170 -9
- data/lib/rfix/extension/string.rb +0 -12
- data/lib/rfix/indicator.rb +0 -19
data/lib/rfix/types.rb
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
require "dry/types"
|
4
4
|
require "dry/logic"
|
5
|
+
require "pathname"
|
6
|
+
require "rugged"
|
5
7
|
|
6
8
|
module Rfix
|
7
9
|
module Types
|
@@ -28,25 +30,33 @@ module Rfix
|
|
28
30
|
|
29
31
|
List = Array(Symbol)
|
30
32
|
|
31
|
-
|
32
|
-
|
33
|
-
|
33
|
+
Deleted = %i[deleted worktree_deleted].map do |status|
|
34
|
+
List.constrained(includes: status)
|
35
|
+
end.reduce(:|)
|
34
36
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
end
|
37
|
+
Ignored = %i[ignored unmodified].map do |status|
|
38
|
+
List.constrained(includes: status)
|
39
|
+
end.reduce(:|)
|
39
40
|
|
40
|
-
|
41
|
+
Untracked = %i[untracked index_new worktree_new].map do |status|
|
42
|
+
List.constrained(includes: status)
|
43
|
+
end.reduce(:|)
|
41
44
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
45
|
+
Tracked = List << (Deleted | Ignored | Untracked).not
|
46
|
+
end
|
47
|
+
|
48
|
+
Dry::Logic::Predicates.predicate(:truthy?) do |attribute, input|
|
49
|
+
!!input.public_send(attribute)
|
50
|
+
rescue NoMethodError
|
51
|
+
false
|
52
|
+
end
|
46
53
|
|
47
|
-
|
48
|
-
|
54
|
+
module Path
|
55
|
+
include Dry::Types()
|
49
56
|
|
57
|
+
Pathname = Constructor(Pathname) << (String | Instance(Pathname))
|
58
|
+
Absolute = Pathname.constrained(truthy: :absolute?)
|
59
|
+
Relative = Pathname.constrained(truthy: :relative?)
|
50
60
|
end
|
51
61
|
end
|
52
62
|
end
|
data/lib/rfix/version.rb
CHANGED
data/rfix.gemspec
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
require_relative "lib/rfix/version"
|
4
4
|
|
5
|
+
$LOAD_PATH.unshift Pathname(__dir__).join("vendor").to_s
|
6
|
+
|
5
7
|
Gem::Specification.new do |spec|
|
6
8
|
spec.name = "rfix"
|
7
9
|
spec.version = Rfix::VERSION
|
@@ -20,14 +22,15 @@ Gem::Specification.new do |spec|
|
|
20
22
|
spec.license = "MIT"
|
21
23
|
spec.required_ruby_version = ">= 2.6"
|
22
24
|
spec.files = Dir["lib/**/*", "exe/rfix", "vendor/**/*", "rfix.gemspec"]
|
23
|
-
spec.executables << "rfix"
|
24
25
|
spec.bindir = "exe"
|
25
|
-
spec.requirements << "git >= 2"
|
26
26
|
|
27
27
|
spec.metadata["homepage_uri"] = spec.homepage
|
28
|
+
spec.executables << "rfix"
|
28
29
|
|
29
30
|
spec.add_runtime_dependency "activesupport"
|
31
|
+
spec.add_runtime_dependency "bootsnap"
|
30
32
|
spec.add_runtime_dependency "bundler"
|
33
|
+
spec.add_runtime_dependency "concurrent-ruby"
|
31
34
|
spec.add_runtime_dependency "dry-cli"
|
32
35
|
spec.add_runtime_dependency "dry-core"
|
33
36
|
spec.add_runtime_dependency "dry-initializer"
|
@@ -38,12 +41,17 @@ Gem::Specification.new do |spec|
|
|
38
41
|
spec.add_runtime_dependency "rake"
|
39
42
|
spec.add_runtime_dependency "rouge", "~> 3.20"
|
40
43
|
spec.add_runtime_dependency "rubocop", ">= 0.82.0", "!= 0.85.0"
|
41
|
-
spec.add_runtime_dependency "rubocop-ast"
|
42
44
|
spec.add_runtime_dependency "rugged"
|
43
45
|
spec.add_runtime_dependency "strings"
|
46
|
+
spec.add_runtime_dependency "strings-ansi"
|
44
47
|
spec.add_runtime_dependency "tty-box"
|
45
48
|
spec.add_runtime_dependency "tty-link"
|
49
|
+
spec.add_runtime_dependency "tty-logger"
|
50
|
+
spec.add_runtime_dependency "tty-progressbar"
|
46
51
|
spec.add_runtime_dependency "tty-prompt"
|
47
52
|
spec.add_runtime_dependency "tty-screen"
|
53
|
+
spec.add_runtime_dependency "tty-table"
|
54
|
+
spec.add_runtime_dependency "tty-tree"
|
55
|
+
spec.add_runtime_dependency "xdg"
|
48
56
|
spec.add_runtime_dependency "zeitwerk"
|
49
57
|
end
|
@@ -0,0 +1,17 @@
|
|
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 'rubocop-shopify'
|
9
|
+
gem 'byebug', platforms: [:mri]
|
10
|
+
gem 'method_source'
|
11
|
+
end
|
12
|
+
|
13
|
+
group :test do
|
14
|
+
gem 'mocha', require: false
|
15
|
+
gem 'minitest', '>= 5.0.0', require: false
|
16
|
+
gem 'minitest-reporters', require: false
|
17
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
cli-ui (1.5.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
ansi (1.5.0)
|
10
|
+
ast (2.4.2)
|
11
|
+
builder (3.2.4)
|
12
|
+
byebug (11.1.3)
|
13
|
+
method_source (1.0.0)
|
14
|
+
minitest (5.14.4)
|
15
|
+
minitest-reporters (1.4.3)
|
16
|
+
ansi
|
17
|
+
builder
|
18
|
+
minitest (>= 5.0)
|
19
|
+
ruby-progressbar
|
20
|
+
mocha (1.12.0)
|
21
|
+
parallel (1.20.1)
|
22
|
+
parser (3.0.0.0)
|
23
|
+
ast (~> 2.4.1)
|
24
|
+
rainbow (3.0.0)
|
25
|
+
rake (13.0.3)
|
26
|
+
regexp_parser (2.1.1)
|
27
|
+
rexml (3.2.5)
|
28
|
+
rubocop (1.12.1)
|
29
|
+
parallel (~> 1.10)
|
30
|
+
parser (>= 3.0.0.0)
|
31
|
+
rainbow (>= 2.2.2, < 4.0)
|
32
|
+
regexp_parser (>= 1.8, < 3.0)
|
33
|
+
rexml
|
34
|
+
rubocop-ast (>= 1.2.0, < 2.0)
|
35
|
+
ruby-progressbar (~> 1.7)
|
36
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
37
|
+
rubocop-ast (1.4.1)
|
38
|
+
parser (>= 2.7.1.5)
|
39
|
+
rubocop-shopify (2.0.1)
|
40
|
+
rubocop (~> 1.11)
|
41
|
+
ruby-progressbar (1.11.0)
|
42
|
+
unicode-display_width (2.0.0)
|
43
|
+
|
44
|
+
PLATFORMS
|
45
|
+
java
|
46
|
+
ruby
|
47
|
+
|
48
|
+
DEPENDENCIES
|
49
|
+
byebug
|
50
|
+
cli-ui!
|
51
|
+
method_source
|
52
|
+
minitest (>= 5.0.0)
|
53
|
+
minitest-reporters
|
54
|
+
mocha
|
55
|
+
rake (~> 13.0)
|
56
|
+
rubocop
|
57
|
+
rubocop-shopify
|
58
|
+
|
59
|
+
BUNDLED WITH
|
60
|
+
2.1.0
|
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Burke Libbey
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
@@ -0,0 +1,224 @@
|
|
1
|
+
CLI UI
|
2
|
+
---
|
3
|
+
|
4
|
+
CLI UI is a small framework for generating nice command-line user interfaces
|
5
|
+
|
6
|
+
- [Master Documentation](http://www.rubydoc.info/github/Shopify/cli-ui/master/CLI/UI)
|
7
|
+
- [Documentation of the Rubygems version](http://www.rubydoc.info/gems/cli-ui/)
|
8
|
+
- [Rubygems](https://rubygems.org/gems/cli-ui)
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
```bash
|
13
|
+
gem install cli-ui
|
14
|
+
```
|
15
|
+
|
16
|
+
or add the following to your Gemfile:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
gem 'cli-ui'
|
20
|
+
```
|
21
|
+
|
22
|
+
In your code, simply add a `require 'cli/ui'`. Most options assume `CLI::UI::StdoutRouter.enable` has been called.
|
23
|
+
|
24
|
+
## Features
|
25
|
+
|
26
|
+
This may not be an exhaustive list. Please check our [documentation](http://www.rubydoc.info/github/Shopify/cli-ui/master/CLI/UI) for more information.
|
27
|
+
|
28
|
+
---
|
29
|
+
|
30
|
+
### Nested framing
|
31
|
+
To handle content flow (see example below)
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
CLI::UI::StdoutRouter.enable
|
35
|
+
CLI::UI::Frame.open('Frame 1') do
|
36
|
+
CLI::UI::Frame.open('Frame 2') { puts "inside frame 2" }
|
37
|
+
puts "inside frame 1"
|
38
|
+
end
|
39
|
+
```
|
40
|
+
|
41
|
+
![Nested Framing](https://user-images.githubusercontent.com/3074765/33799861-cb5dcb5c-dd01-11e7-977e-6fad38cee08c.png)
|
42
|
+
|
43
|
+
---
|
44
|
+
|
45
|
+
### Interactive Prompts
|
46
|
+
Prompt user with options and ask them to choose. Can answer using arrow keys, vim bindings (`j`/`k`), or numbers (or y/n for yes/no questions).
|
47
|
+
|
48
|
+
For large numbers of options, using `e`, `:`, or `G` will toggle "line select" mode which allows numbers greater than 9 to be typed and
|
49
|
+
`f` or `/` will allow the user to filter options using a free-form text input.
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
CLI::UI.ask('What language/framework do you use?', options: %w(rails go ruby python))
|
53
|
+
```
|
54
|
+
|
55
|
+
Can also assign callbacks to each option
|
56
|
+
|
57
|
+
```ruby
|
58
|
+
CLI::UI::Prompt.ask('What language/framework do you use?') do |handler|
|
59
|
+
handler.option('rails') { |selection| selection }
|
60
|
+
handler.option('go') { |selection| selection }
|
61
|
+
handler.option('ruby') { |selection| selection }
|
62
|
+
handler.option('python') { |selection| selection }
|
63
|
+
end
|
64
|
+
```
|
65
|
+
|
66
|
+
* Note that the two examples provided above are identical in functionality
|
67
|
+
|
68
|
+
![Interactive Prompt](https://user-images.githubusercontent.com/3074765/33797984-0ebb5e64-dcdf-11e7-9e7e-7204f279cece.gif)
|
69
|
+
|
70
|
+
---
|
71
|
+
|
72
|
+
### Free form text prompts
|
73
|
+
|
74
|
+
```ruby
|
75
|
+
CLI::UI.ask('Is CLI UI Awesome?', default: 'It is great!')
|
76
|
+
```
|
77
|
+
|
78
|
+
![Free form text prompt](https://user-images.githubusercontent.com/3074765/33799822-47f23302-dd01-11e7-82f3-9072a5a5f611.png)
|
79
|
+
|
80
|
+
---
|
81
|
+
|
82
|
+
### Spinner groups
|
83
|
+
Handle many multi-threaded processes while suppressing output unless there is an issue. Can update title to show state.
|
84
|
+
|
85
|
+
```ruby
|
86
|
+
spin_group = CLI::UI::SpinGroup.new
|
87
|
+
spin_group.add('Title') { |spinner| sleep 3.0 }
|
88
|
+
spin_group.add('Title 2') { |spinner| sleep 3.0; spinner.update_title('New Title'); sleep 3.0 }
|
89
|
+
spin_group.wait
|
90
|
+
```
|
91
|
+
|
92
|
+
![Spinner Group](https://user-images.githubusercontent.com/3074765/33798295-d94fd822-dce3-11e7-819b-43e5502d490e.gif)
|
93
|
+
|
94
|
+
---
|
95
|
+
|
96
|
+
### Text Color formatting
|
97
|
+
e.g. `{{red:Red}} {{green:Green}}`
|
98
|
+
|
99
|
+
```ruby
|
100
|
+
puts CLI::UI.fmt "{{red:Red}} {{green:Green}}"
|
101
|
+
```
|
102
|
+
|
103
|
+
![Text Format](https://user-images.githubusercontent.com/3074765/33799827-6d0721a2-dd01-11e7-9ab5-c3d455264afe.png)
|
104
|
+
|
105
|
+
---
|
106
|
+
|
107
|
+
### Symbol/Glyph Formatting
|
108
|
+
e.g. `{{*}}` => a yellow ⭑
|
109
|
+
|
110
|
+
```ruby
|
111
|
+
puts CLI::UI.fmt "{{*}} {{v}} {{?}} {{x}}"
|
112
|
+
```
|
113
|
+
|
114
|
+
![Symbol Formatting](https://user-images.githubusercontent.com/3074765/33799847-9ec03fd0-dd01-11e7-93f7-5f5cc540e61e.png)
|
115
|
+
|
116
|
+
---
|
117
|
+
|
118
|
+
### Status Widget
|
119
|
+
|
120
|
+
```ruby
|
121
|
+
CLI::UI::Spinner.spin("building packages: {{@widget/status:1:2:3:4}}") do |spinner|
|
122
|
+
# spinner.update_title(...)
|
123
|
+
sleep(3)
|
124
|
+
end
|
125
|
+
```
|
126
|
+
|
127
|
+
![Status Widget](https://user-images.githubusercontent.com/1284/61405142-11042580-a8a7-11e9-9885-46ba44c46358.gif)
|
128
|
+
|
129
|
+
---
|
130
|
+
|
131
|
+
### Progress Bar
|
132
|
+
|
133
|
+
Show progress of a process or operation.
|
134
|
+
|
135
|
+
```ruby
|
136
|
+
CLI::UI::Progress.progress do |bar|
|
137
|
+
100.times do
|
138
|
+
bar.tick
|
139
|
+
end
|
140
|
+
end
|
141
|
+
```
|
142
|
+
|
143
|
+
![Progress Bar](https://user-images.githubusercontent.com/3074765/33799794-cc4c940e-dd00-11e7-9bdc-90f77ec9167c.gif)
|
144
|
+
|
145
|
+
---
|
146
|
+
|
147
|
+
### Frame Styles
|
148
|
+
|
149
|
+
Modify the appearance of CLI::UI both globally and on an individual frame level.
|
150
|
+
|
151
|
+
To set the default style:
|
152
|
+
|
153
|
+
```ruby
|
154
|
+
CLI::UI.frame_style = :box
|
155
|
+
```
|
156
|
+
|
157
|
+
To style an individual frame:
|
158
|
+
|
159
|
+
```ruby
|
160
|
+
CLI::UI.frame('New Style!', frame_style: :bracket) { puts 'It's pretty cool!' }
|
161
|
+
```
|
162
|
+
|
163
|
+
The default style - `:box` - is what has been used up until now. The other style - `:bracket` - looks like this:
|
164
|
+
|
165
|
+
```ruby
|
166
|
+
CLI::UI.frame_style = :bracket
|
167
|
+
CLI::UI::StdoutRouter.enable
|
168
|
+
CLI::UI::Frame.open('Frame 1') do
|
169
|
+
CLI::UI::Frame.open('Frame 2') { puts "inside frame 2" }
|
170
|
+
puts "inside frame 1"
|
171
|
+
end
|
172
|
+
```
|
173
|
+
|
174
|
+
![Frame Style](https://user-images.githubusercontent.com/315948/65287373-9a82de80-db08-11e9-94fb-20f4b7561c07.png)
|
175
|
+
|
176
|
+
---
|
177
|
+
|
178
|
+
## Example Usage
|
179
|
+
|
180
|
+
The following code makes use of nested-framing, multi-threaded spinners, formatted text, and more.
|
181
|
+
|
182
|
+
```ruby
|
183
|
+
require 'cli/ui'
|
184
|
+
|
185
|
+
CLI::UI::StdoutRouter.enable
|
186
|
+
|
187
|
+
CLI::UI::Frame.open('{{*}} {{bold:a}}', color: :green) do
|
188
|
+
CLI::UI::Frame.open('{{i}} b', color: :magenta) do
|
189
|
+
CLI::UI::Frame.open('{{?}} c', color: :cyan) do
|
190
|
+
sg = CLI::UI::SpinGroup.new
|
191
|
+
sg.add('wow') do |spinner|
|
192
|
+
sleep(2.5)
|
193
|
+
spinner.update_title('second round!')
|
194
|
+
sleep (1.0)
|
195
|
+
end
|
196
|
+
sg.add('such spin') { sleep(1.6) }
|
197
|
+
sg.add('many glyph') { sleep(2.0) }
|
198
|
+
sg.wait
|
199
|
+
end
|
200
|
+
end
|
201
|
+
CLI::UI::Frame.divider('{{v}} lol')
|
202
|
+
puts CLI::UI.fmt '{{info:words}} {{red:oh no!}} {{green:success!}}'
|
203
|
+
sg = CLI::UI::SpinGroup.new
|
204
|
+
sg.add('more spins') { sleep(0.5) ; raise 'oh no' }
|
205
|
+
sg.wait
|
206
|
+
end
|
207
|
+
```
|
208
|
+
|
209
|
+
Output:
|
210
|
+
|
211
|
+
![Example Output](https://user-images.githubusercontent.com/3074765/33797758-7a54c7cc-dcdb-11e7-918e-a47c9689f068.gif)
|
212
|
+
|
213
|
+
## Development
|
214
|
+
|
215
|
+
- Run tests using `bundle exec rake test`. All code should be tested.
|
216
|
+
- No code, outside of development and tests needs, should use dependencies. This is a self contained library
|
217
|
+
|
218
|
+
## Contributing
|
219
|
+
|
220
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/Shopify/cli-ui.
|
221
|
+
|
222
|
+
## License
|
223
|
+
|
224
|
+
The code is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
@@ -0,0 +1,20 @@
|
|
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, :style])
|