rfix 2.0.4 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/exe/rfix +11 -90
  3. data/lib/rfix.rb +10 -9
  4. data/lib/rfix/branch/reference.rb +2 -2
  5. data/lib/rfix/branch/upstream.rb +2 -4
  6. data/lib/rfix/cli/command.rb +14 -1
  7. data/lib/rfix/cli/command/all.rb +21 -0
  8. data/lib/rfix/cli/command/base.rb +30 -19
  9. data/lib/rfix/cli/command/branch.rb +2 -0
  10. data/lib/rfix/cli/command/help.rb +2 -0
  11. data/lib/rfix/cli/command/info.rb +6 -1
  12. data/lib/rfix/cli/command/local.rb +2 -0
  13. data/lib/rfix/cli/command/origin.rb +2 -0
  14. data/lib/rfix/cli/command/setup.rb +2 -0
  15. data/lib/rfix/cli/command/status.rb +39 -0
  16. data/lib/rfix/collector.rb +69 -0
  17. data/lib/rfix/diff.rb +69 -0
  18. data/lib/rfix/extension/comment_config.rb +15 -0
  19. data/lib/rfix/extension/offense.rb +17 -14
  20. data/lib/rfix/extension/pastel.rb +7 -4
  21. data/lib/rfix/extension/progresbar.rb +15 -0
  22. data/lib/rfix/extension/strings.rb +10 -2
  23. data/lib/rfix/file.rb +5 -3
  24. data/lib/rfix/file/base.rb +21 -14
  25. data/lib/rfix/file/deleted.rb +2 -0
  26. data/lib/rfix/file/ignored.rb +2 -0
  27. data/lib/rfix/file/null.rb +17 -0
  28. data/lib/rfix/file/tracked.rb +39 -23
  29. data/lib/rfix/file/undefined.rb +17 -0
  30. data/lib/rfix/file/untracked.rb +3 -1
  31. data/lib/rfix/formatter.rb +67 -71
  32. data/lib/rfix/highlighter.rb +1 -3
  33. data/lib/rfix/rake/gemfile.rb +26 -23
  34. data/lib/rfix/repository.rb +59 -96
  35. data/lib/rfix/types.rb +24 -14
  36. data/lib/rfix/version.rb +1 -1
  37. data/rfix.gemspec +11 -3
  38. data/vendor/cli-ui/Gemfile +17 -0
  39. data/vendor/cli-ui/Gemfile.lock +60 -0
  40. data/vendor/cli-ui/LICENSE.txt +21 -0
  41. data/vendor/cli-ui/README.md +224 -0
  42. data/vendor/cli-ui/Rakefile +20 -0
  43. data/vendor/cli-ui/bin/console +14 -0
  44. data/vendor/cli-ui/cli-ui.gemspec +25 -0
  45. data/vendor/cli-ui/dev.yml +14 -0
  46. data/vendor/cli-ui/lib/cli/ui.rb +233 -0
  47. data/vendor/cli-ui/lib/cli/ui/ansi.rb +157 -0
  48. data/vendor/cli-ui/lib/cli/ui/color.rb +84 -0
  49. data/vendor/cli-ui/lib/cli/ui/formatter.rb +192 -0
  50. data/vendor/cli-ui/lib/cli/ui/frame.rb +269 -0
  51. data/vendor/cli-ui/lib/cli/ui/frame/frame_stack.rb +98 -0
  52. data/vendor/cli-ui/lib/cli/ui/frame/frame_style.rb +120 -0
  53. data/vendor/cli-ui/lib/cli/ui/frame/frame_style/box.rb +166 -0
  54. data/vendor/cli-ui/lib/cli/ui/frame/frame_style/bracket.rb +139 -0
  55. data/vendor/cli-ui/lib/cli/ui/glyph.rb +84 -0
  56. data/vendor/cli-ui/lib/cli/ui/os.rb +67 -0
  57. data/vendor/cli-ui/lib/cli/ui/printer.rb +59 -0
  58. data/vendor/cli-ui/lib/cli/ui/progress.rb +90 -0
  59. data/vendor/cli-ui/lib/cli/ui/prompt.rb +297 -0
  60. data/vendor/cli-ui/lib/cli/ui/prompt/interactive_options.rb +484 -0
  61. data/vendor/cli-ui/lib/cli/ui/prompt/options_handler.rb +29 -0
  62. data/vendor/cli-ui/lib/cli/ui/spinner.rb +66 -0
  63. data/vendor/cli-ui/lib/cli/ui/spinner/async.rb +40 -0
  64. data/vendor/cli-ui/lib/cli/ui/spinner/spin_group.rb +263 -0
  65. data/vendor/cli-ui/lib/cli/ui/stdout_router.rb +232 -0
  66. data/vendor/cli-ui/lib/cli/ui/terminal.rb +46 -0
  67. data/vendor/cli-ui/lib/cli/ui/truncater.rb +102 -0
  68. data/vendor/cli-ui/lib/cli/ui/version.rb +5 -0
  69. data/vendor/cli-ui/lib/cli/ui/widgets.rb +77 -0
  70. data/vendor/cli-ui/lib/cli/ui/widgets/base.rb +27 -0
  71. data/vendor/cli-ui/lib/cli/ui/widgets/status.rb +61 -0
  72. data/vendor/cli-ui/lib/cli/ui/wrap.rb +56 -0
  73. data/vendor/cli-ui/test/cli/ui/ansi_test.rb +32 -0
  74. data/vendor/cli-ui/test/cli/ui/cli_ui_test.rb +23 -0
  75. data/vendor/cli-ui/test/cli/ui/color_test.rb +40 -0
  76. data/vendor/cli-ui/test/cli/ui/formatter_test.rb +79 -0
  77. data/vendor/cli-ui/test/cli/ui/glyph_test.rb +68 -0
  78. data/vendor/cli-ui/test/cli/ui/printer_test.rb +103 -0
  79. data/vendor/cli-ui/test/cli/ui/progress_test.rb +46 -0
  80. data/vendor/cli-ui/test/cli/ui/prompt/options_handler_test.rb +39 -0
  81. data/vendor/cli-ui/test/cli/ui/prompt_test.rb +348 -0
  82. data/vendor/cli-ui/test/cli/ui/spinner/spin_group_test.rb +39 -0
  83. data/vendor/cli-ui/test/cli/ui/spinner_test.rb +141 -0
  84. data/vendor/cli-ui/test/cli/ui/stdout_router_test.rb +32 -0
  85. data/vendor/cli-ui/test/cli/ui/terminal_test.rb +26 -0
  86. data/vendor/cli-ui/test/cli/ui/truncater_test.rb +31 -0
  87. data/vendor/cli-ui/test/cli/ui/widgets/status_test.rb +49 -0
  88. data/vendor/cli-ui/test/cli/ui/widgets_test.rb +15 -0
  89. data/vendor/cli-ui/test/test_helper.rb +53 -0
  90. data/vendor/cli-ui/tmp/cache/bootsnap/compile-cache/d9/c036af0f3dc494 +0 -0
  91. data/vendor/cli-ui/tmp/cache/bootsnap/load-path-cache +0 -0
  92. data/vendor/dry-cli/lib/dry/cli/command.rb +2 -1
  93. data/vendor/dry-cli/tmp/cache/bootsnap/compile-cache/ff/a22a5daafbd74c +0 -0
  94. data/vendor/dry-cli/tmp/cache/bootsnap/load-path-cache +0 -0
  95. data/vendor/strings-ansi/tmp/cache/bootsnap/compile-cache/79/49cf49407b370e +0 -0
  96. data/vendor/strings-ansi/tmp/cache/bootsnap/load-path-cache +0 -0
  97. metadata +170 -9
  98. data/lib/rfix/extension/string.rb +0 -12
  99. data/lib/rfix/indicator.rb +0 -19
@@ -0,0 +1,14 @@
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__)
@@ -0,0 +1,25 @@
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 = Dir['lib/**/*.rb', 'README.md', 'LICENSE.txt']
18
+ spec.bindir = 'exe'
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ['lib']
21
+
22
+ # spec.add_development_dependency "bundler", "~> 2.0"
23
+ spec.add_development_dependency('rake', '~> 13.0')
24
+ spec.add_development_dependency('minitest', '~> 5.0')
25
+ end
@@ -0,0 +1,14 @@
1
+ up:
2
+ - ruby: 2.5.1
3
+ - bundler
4
+
5
+ commands:
6
+ test:
7
+ run: |
8
+ if [ "$#" -eq 1 ] && [[ -f $1 ]];
9
+ then
10
+ rake test TEST=$1
11
+ else
12
+ rake test $@
13
+ fi
14
+ style: "bundle exec rubocop -D"
@@ -0,0 +1,233 @@
1
+ module CLI
2
+ module UI
3
+ autoload :ANSI, 'cli/ui/ansi'
4
+ autoload :Glyph, 'cli/ui/glyph'
5
+ autoload :Color, 'cli/ui/color'
6
+ autoload :Frame, 'cli/ui/frame'
7
+ autoload :OS, 'cli/ui/os'
8
+ autoload :Printer, 'cli/ui/printer'
9
+ autoload :Progress, 'cli/ui/progress'
10
+ autoload :Prompt, 'cli/ui/prompt'
11
+ autoload :Terminal, 'cli/ui/terminal'
12
+ autoload :Truncater, 'cli/ui/truncater'
13
+ autoload :Formatter, 'cli/ui/formatter'
14
+ autoload :Spinner, 'cli/ui/spinner'
15
+ autoload :Widgets, 'cli/ui/widgets'
16
+ autoload :Wrap, 'cli/ui/wrap'
17
+
18
+ # Convenience accessor to +CLI::UI::Spinner::SpinGroup+
19
+ SpinGroup = Spinner::SpinGroup
20
+
21
+ # Glyph resolution using +CLI::UI::Glyph.lookup+
22
+ # Look at the method signature for +Glyph.lookup+ for more details
23
+ #
24
+ # ==== Attributes
25
+ #
26
+ # * +handle+ - handle of the glyph to resolve
27
+ #
28
+ def self.glyph(handle)
29
+ CLI::UI::Glyph.lookup(handle)
30
+ end
31
+
32
+ # Color resolution using +CLI::UI::Color.lookup+
33
+ # Will lookup using +Color.lookup+ unless it's already a CLI::UI::Color (or nil)
34
+ #
35
+ # ==== Attributes
36
+ #
37
+ # * +input+ - color to resolve
38
+ #
39
+ def self.resolve_color(input)
40
+ case input
41
+ when CLI::UI::Color, nil
42
+ input
43
+ else
44
+ CLI::UI::Color.lookup(input)
45
+ end
46
+ end
47
+
48
+ # Frame style resolution using +CLI::UI::Frame::FrameStyle.lookup+.
49
+ # Will lookup using +FrameStyle.lookup+ unless it's already a CLI::UI::Frame::FrameStyle(or nil)
50
+ #
51
+ # ==== Attributes
52
+ #
53
+ # * +input+ - frame style to resolve
54
+ def self.resolve_style(input)
55
+ case input
56
+ when CLI::UI::Frame::FrameStyle, nil
57
+ input
58
+ else
59
+ CLI::UI::Frame::FrameStyle.lookup(input)
60
+ end
61
+ end
62
+
63
+ # Convenience Method for +CLI::UI::Prompt.confirm+
64
+ #
65
+ # ==== Attributes
66
+ #
67
+ # * +question+ - question to confirm
68
+ #
69
+ def self.confirm(question, **kwargs)
70
+ CLI::UI::Prompt.confirm(question, **kwargs)
71
+ end
72
+
73
+ # Convenience Method for +CLI::UI::Prompt.ask+
74
+ #
75
+ # ==== Attributes
76
+ #
77
+ # * +question+ - question to ask
78
+ # * +kwargs+ - arguments for +Prompt.ask+
79
+ #
80
+ def self.ask(question, **kwargs)
81
+ CLI::UI::Prompt.ask(question, **kwargs)
82
+ end
83
+
84
+ # Convenience Method to resolve text using +CLI::UI::Formatter.format+
85
+ # Check +CLI::UI::Formatter::SGR_MAP+ for available formatting options
86
+ #
87
+ # ==== Attributes
88
+ #
89
+ # * +input+ - input to format
90
+ # * +truncate_to+ - number of characters to truncate the string to (or nil)
91
+ #
92
+ def self.resolve_text(input, truncate_to: nil)
93
+ return input if input.nil?
94
+ formatted = CLI::UI::Formatter.new(input).format
95
+ return formatted unless truncate_to
96
+ CLI::UI::Truncater.call(formatted, truncate_to)
97
+ end
98
+
99
+ # Convenience Method to format text using +CLI::UI::Formatter.format+
100
+ # Check +CLI::UI::Formatter::SGR_MAP+ for available formatting options
101
+ #
102
+ # https://user-images.githubusercontent.com/3074765/33799827-6d0721a2-dd01-11e7-9ab5-c3d455264afe.png
103
+ # https://user-images.githubusercontent.com/3074765/33799847-9ec03fd0-dd01-11e7-93f7-5f5cc540e61e.png
104
+ #
105
+ # ==== Attributes
106
+ #
107
+ # * +input+ - input to format
108
+ #
109
+ # ==== Options
110
+ #
111
+ # * +enable_color+ - should color be used? default to true unless output is redirected.
112
+ #
113
+ def self.fmt(input, enable_color: enable_color?)
114
+ CLI::UI::Formatter.new(input).format(enable_color: enable_color)
115
+ end
116
+
117
+ def self.wrap(input)
118
+ CLI::UI::Wrap.new(input).wrap
119
+ end
120
+
121
+ # Convenience Method for +CLI::UI::Printer.puts+
122
+ #
123
+ # ==== Attributes
124
+ #
125
+ # * +msg+ - Message to print
126
+ # * +kwargs+ - keyword arguments for +Printer.puts+
127
+ #
128
+ def self.puts(msg, **kwargs)
129
+ CLI::UI::Printer.puts(msg, **kwargs)
130
+ end
131
+
132
+ # Convenience Method for +CLI::UI::Frame.open+
133
+ #
134
+ # ==== Attributes
135
+ #
136
+ # * +args+ - arguments for +Frame.open+
137
+ # * +block+ - block for +Frame.open+
138
+ #
139
+ def self.frame(*args, **kwargs, &block)
140
+ CLI::UI::Frame.open(*args, **kwargs, &block)
141
+ end
142
+
143
+ # Convenience Method for +CLI::UI::Spinner.spin+
144
+ #
145
+ # ==== Attributes
146
+ #
147
+ # * +args+ - arguments for +Spinner.open+
148
+ # * +block+ - block for +Spinner.open+
149
+ #
150
+ def self.spinner(*args, **kwargs, &block)
151
+ CLI::UI::Spinner.spin(*args, **kwargs, &block)
152
+ end
153
+
154
+ # Convenience Method to override frame color using +CLI::UI::Frame.with_frame_color+
155
+ #
156
+ # ==== Attributes
157
+ #
158
+ # * +color+ - color to override to
159
+ # * +block+ - block for +Frame.with_frame_color_override+
160
+ #
161
+ def self.with_frame_color(color, &block)
162
+ CLI::UI::Frame.with_frame_color_override(color, &block)
163
+ end
164
+
165
+ # Duplicate output to a file path
166
+ #
167
+ # ==== Attributes
168
+ #
169
+ # * +path+ - path to duplicate output to
170
+ #
171
+ def self.log_output_to(path)
172
+ if CLI::UI::StdoutRouter.duplicate_output_to
173
+ raise 'multiple logs not allowed'
174
+ end
175
+ CLI::UI::StdoutRouter.duplicate_output_to = File.open(path, 'w')
176
+ yield
177
+ ensure
178
+ if (file_descriptor = CLI::UI::StdoutRouter.duplicate_output_to)
179
+ file_descriptor.close
180
+ CLI::UI::StdoutRouter.duplicate_output_to = nil
181
+ end
182
+ end
183
+
184
+ # Disable all framing within a block
185
+ #
186
+ # ==== Attributes
187
+ #
188
+ # * +block+ - block in which to disable frames
189
+ #
190
+ def self.raw
191
+ prev = Thread.current[:no_cliui_frame_inset]
192
+ Thread.current[:no_cliui_frame_inset] = true
193
+ yield
194
+ ensure
195
+ Thread.current[:no_cliui_frame_inset] = prev
196
+ end
197
+
198
+ # Check whether colour is enabled in Formatter output. By default, colour
199
+ # is enabled when STDOUT is a TTY; that is, when output has not been
200
+ # redirected to another program or to a file.
201
+ #
202
+ def self.enable_color?
203
+ @enable_color
204
+ end
205
+
206
+ # Turn colour output in Formatter on or off.
207
+ #
208
+ # ==== Attributes
209
+ #
210
+ # * +bool+ - true or false; enable or disable colour.
211
+ #
212
+ def self.enable_color=(bool)
213
+ @enable_color = !!bool
214
+ end
215
+
216
+ self.enable_color = $stdout.tty?
217
+
218
+ # Set the default frame style.
219
+ # Convenience method for setting the default frame style with +CLI::UI::Frame.frame_style=+
220
+ #
221
+ # Raises ArgumentError if +frame_style+ is not valid
222
+ #
223
+ # ==== Attributes
224
+ #
225
+ # * +symbol+ - the default frame style to use for frames
226
+ #
227
+ def self.frame_style=(frame_style)
228
+ Frame.frame_style = frame_style.to_sym
229
+ end
230
+ end
231
+ end
232
+
233
+ require 'cli/ui/stdout_router'
@@ -0,0 +1,157 @@
1
+ require 'cli/ui'
2
+
3
+ module CLI
4
+ module UI
5
+ module ANSI
6
+ ESC = "\x1b"
7
+
8
+ # ANSI escape sequences (like \x1b[31m) have zero width.
9
+ # when calculating the padding width, we must exclude them.
10
+ # This also implements a basic version of utf8 character width calculation like
11
+ # we could get for real from something like utf8proc.
12
+ #
13
+ def self.printing_width(str)
14
+ zwj = false
15
+ strip_codes(str).codepoints.reduce(0) do |acc, cp|
16
+ if zwj
17
+ zwj = false
18
+ next acc
19
+ end
20
+ case cp
21
+ when 0x200d # zero-width joiner
22
+ zwj = true
23
+ acc
24
+ when "\n"
25
+ acc
26
+ else
27
+ acc + 1
28
+ end
29
+ end
30
+ end
31
+
32
+ # Strips ANSI codes from a str
33
+ #
34
+ # ==== Attributes
35
+ #
36
+ # - +str+ - The string from which to strip codes
37
+ #
38
+ def self.strip_codes(str)
39
+ str.gsub(/\x1b\[[\d;]+[A-z]|\r/, '')
40
+ end
41
+
42
+ # Returns an ANSI control sequence
43
+ #
44
+ # ==== Attributes
45
+ #
46
+ # - +args+ - Argument to pass to the ANSI control sequence
47
+ # - +cmd+ - ANSI control sequence Command
48
+ #
49
+ def self.control(args, cmd)
50
+ ESC + '[' + args + cmd
51
+ end
52
+
53
+ # https://en.wikipedia.org/wiki/ANSI_escape_code#graphics
54
+ def self.sgr(params)
55
+ control(params.to_s, 'm')
56
+ end
57
+
58
+ # Cursor Movement
59
+
60
+ # Move the cursor up n lines
61
+ #
62
+ # ==== Attributes
63
+ #
64
+ # * +n+ - number of lines by which to move the cursor up
65
+ #
66
+ def self.cursor_up(n = 1)
67
+ return '' if n.zero?
68
+ control(n.to_s, 'A')
69
+ end
70
+
71
+ # Move the cursor down n lines
72
+ #
73
+ # ==== Attributes
74
+ #
75
+ # * +n+ - number of lines by which to move the cursor down
76
+ #
77
+ def self.cursor_down(n = 1)
78
+ return '' if n.zero?
79
+ control(n.to_s, 'B')
80
+ end
81
+
82
+ # Move the cursor forward n columns
83
+ #
84
+ # ==== Attributes
85
+ #
86
+ # * +n+ - number of columns by which to move the cursor forward
87
+ #
88
+ def self.cursor_forward(n = 1)
89
+ return '' if n.zero?
90
+ control(n.to_s, 'C')
91
+ end
92
+
93
+ # Move the cursor back n columns
94
+ #
95
+ # ==== Attributes
96
+ #
97
+ # * +n+ - number of columns by which to move the cursor back
98
+ #
99
+ def self.cursor_back(n = 1)
100
+ return '' if n.zero?
101
+ control(n.to_s, 'D')
102
+ end
103
+
104
+ # Move the cursor to a specific column
105
+ #
106
+ # ==== Attributes
107
+ #
108
+ # * +n+ - The column to move to
109
+ #
110
+ def self.cursor_horizontal_absolute(n = 1)
111
+ cmd = control(n.to_s, 'G')
112
+ cmd += control('1', 'D') if CLI::UI::OS.current.shift_cursor_on_line_reset?
113
+ cmd
114
+ end
115
+
116
+ # Show the cursor
117
+ #
118
+ def self.show_cursor
119
+ control('', '?25h')
120
+ end
121
+
122
+ # Hide the cursor
123
+ #
124
+ def self.hide_cursor
125
+ control('', '?25l')
126
+ end
127
+
128
+ # Save the cursor position
129
+ #
130
+ def self.cursor_save
131
+ control('', 's')
132
+ end
133
+
134
+ # Restore the saved cursor position
135
+ #
136
+ def self.cursor_restore
137
+ control('', 'u')
138
+ end
139
+
140
+ # Move to the next line
141
+ #
142
+ def self.next_line
143
+ cursor_down + cursor_horizontal_absolute
144
+ end
145
+
146
+ # Move to the previous line
147
+ #
148
+ def self.previous_line
149
+ cursor_up + cursor_horizontal_absolute
150
+ end
151
+
152
+ def self.clear_to_end_of_line
153
+ control('', 'K')
154
+ end
155
+ end
156
+ end
157
+ end