doing 2.0.17 → 2.0.21
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/CHANGELOG.md +30 -0
- data/Gemfile.lock +15 -5
- data/README.md +1 -1
- data/bin/doing +2 -18
- data/doing.gemspec +5 -4
- data/doing.rdoc +2 -2
- data/generate_completions.sh +3 -3
- data/lib/completion/_doing.zsh +19 -19
- data/lib/completion/doing.bash +28 -28
- data/lib/completion/doing.fish +0 -14
- data/lib/doing/cli_status.rb +6 -2
- data/lib/doing/completion/bash_completion.rb +185 -0
- data/lib/doing/completion/fish_completion.rb +175 -0
- data/lib/doing/completion/string.rb +17 -0
- data/lib/doing/completion/zsh_completion.rb +140 -0
- data/lib/doing/completion.rb +39 -0
- data/lib/doing/plugins/export/template_export.rb +3 -1
- data/lib/doing/string.rb +1 -1
- data/lib/doing/version.rb +1 -1
- data/lib/doing/wwid.rb +22 -8
- data/lib/doing.rb +1 -1
- data/lib/helpers/fzf/.goreleaser.yml +119 -0
- data/lib/helpers/fzf/.rubocop.yml +28 -0
- data/lib/helpers/fzf/ADVANCED.md +565 -0
- data/lib/helpers/fzf/BUILD.md +49 -0
- data/lib/helpers/fzf/CHANGELOG.md +1193 -0
- data/lib/helpers/fzf/Dockerfile +11 -0
- data/lib/helpers/fzf/LICENSE +21 -0
- data/lib/helpers/fzf/Makefile +166 -0
- data/lib/helpers/fzf/README-VIM.md +486 -0
- data/lib/helpers/fzf/README.md +712 -0
- data/lib/helpers/fzf/bin/fzf-tmux +233 -0
- data/lib/helpers/fzf/doc/fzf.txt +512 -0
- data/lib/helpers/fzf/go.mod +17 -0
- data/lib/helpers/fzf/go.sum +31 -0
- data/lib/helpers/fzf/install +382 -0
- data/lib/helpers/fzf/install.ps1 +65 -0
- data/lib/helpers/fzf/main.go +14 -0
- data/lib/helpers/fzf/man/man1/fzf-tmux.1 +68 -0
- data/lib/helpers/fzf/man/man1/fzf.1 +1001 -0
- data/lib/helpers/fzf/plugin/fzf.vim +1048 -0
- data/lib/helpers/fzf/shell/completion.bash +381 -0
- data/lib/helpers/fzf/shell/completion.zsh +329 -0
- data/lib/helpers/fzf/shell/key-bindings.bash +96 -0
- data/lib/helpers/fzf/shell/key-bindings.fish +172 -0
- data/lib/helpers/fzf/shell/key-bindings.zsh +114 -0
- data/lib/helpers/fzf/src/LICENSE +21 -0
- data/lib/helpers/fzf/src/algo/algo.go +884 -0
- data/lib/helpers/fzf/src/algo/algo_test.go +197 -0
- data/lib/helpers/fzf/src/algo/normalize.go +492 -0
- data/lib/helpers/fzf/src/ansi.go +409 -0
- data/lib/helpers/fzf/src/ansi_test.go +427 -0
- data/lib/helpers/fzf/src/cache.go +81 -0
- data/lib/helpers/fzf/src/cache_test.go +39 -0
- data/lib/helpers/fzf/src/chunklist.go +89 -0
- data/lib/helpers/fzf/src/chunklist_test.go +80 -0
- data/lib/helpers/fzf/src/constants.go +85 -0
- data/lib/helpers/fzf/src/core.go +351 -0
- data/lib/helpers/fzf/src/history.go +96 -0
- data/lib/helpers/fzf/src/history_test.go +68 -0
- data/lib/helpers/fzf/src/item.go +44 -0
- data/lib/helpers/fzf/src/item_test.go +23 -0
- data/lib/helpers/fzf/src/matcher.go +235 -0
- data/lib/helpers/fzf/src/merger.go +120 -0
- data/lib/helpers/fzf/src/merger_test.go +88 -0
- data/lib/helpers/fzf/src/options.go +1691 -0
- data/lib/helpers/fzf/src/options_test.go +457 -0
- data/lib/helpers/fzf/src/pattern.go +425 -0
- data/lib/helpers/fzf/src/pattern_test.go +209 -0
- data/lib/helpers/fzf/src/protector/protector.go +8 -0
- data/lib/helpers/fzf/src/protector/protector_openbsd.go +10 -0
- data/lib/helpers/fzf/src/reader.go +201 -0
- data/lib/helpers/fzf/src/reader_test.go +63 -0
- data/lib/helpers/fzf/src/result.go +243 -0
- data/lib/helpers/fzf/src/result_others.go +16 -0
- data/lib/helpers/fzf/src/result_test.go +159 -0
- data/lib/helpers/fzf/src/result_x86.go +16 -0
- data/lib/helpers/fzf/src/terminal.go +2832 -0
- data/lib/helpers/fzf/src/terminal_test.go +638 -0
- data/lib/helpers/fzf/src/terminal_unix.go +26 -0
- data/lib/helpers/fzf/src/terminal_windows.go +45 -0
- data/lib/helpers/fzf/src/tokenizer.go +253 -0
- data/lib/helpers/fzf/src/tokenizer_test.go +112 -0
- data/lib/helpers/fzf/src/tui/dummy.go +46 -0
- data/lib/helpers/fzf/src/tui/light.go +987 -0
- data/lib/helpers/fzf/src/tui/light_unix.go +110 -0
- data/lib/helpers/fzf/src/tui/light_windows.go +145 -0
- data/lib/helpers/fzf/src/tui/tcell.go +721 -0
- data/lib/helpers/fzf/src/tui/tcell_test.go +392 -0
- data/lib/helpers/fzf/src/tui/ttyname_unix.go +47 -0
- data/lib/helpers/fzf/src/tui/ttyname_windows.go +14 -0
- data/lib/helpers/fzf/src/tui/tui.go +625 -0
- data/lib/helpers/fzf/src/tui/tui_test.go +20 -0
- data/lib/helpers/fzf/src/util/atomicbool.go +34 -0
- data/lib/helpers/fzf/src/util/atomicbool_test.go +17 -0
- data/lib/helpers/fzf/src/util/chars.go +198 -0
- data/lib/helpers/fzf/src/util/chars_test.go +46 -0
- data/lib/helpers/fzf/src/util/eventbox.go +96 -0
- data/lib/helpers/fzf/src/util/eventbox_test.go +61 -0
- data/lib/helpers/fzf/src/util/slab.go +12 -0
- data/lib/helpers/fzf/src/util/util.go +138 -0
- data/lib/helpers/fzf/src/util/util_test.go +40 -0
- data/lib/helpers/fzf/src/util/util_unix.go +47 -0
- data/lib/helpers/fzf/src/util/util_windows.go +83 -0
- data/lib/helpers/fzf/test/fzf.vader +175 -0
- data/lib/helpers/fzf/test/test_go.rb +2626 -0
- data/lib/helpers/fzf/uninstall +117 -0
- data/scripts/generate_bash_completions.rb +6 -12
- data/scripts/generate_fish_completions.rb +7 -16
- data/scripts/generate_zsh_completions.rb +6 -15
- metadata +145 -10
data/lib/completion/doing.fish
CHANGED
|
@@ -99,7 +99,6 @@ complete -xc doing -n '__fish_doing_needs_command' -a 'yesterday' -d List\ entri
|
|
|
99
99
|
complete -c doing -l bool -f -r -n '__fish_doing_using_command again resume' -d Boolean\ used\ to\ combine\ multiple\ tags
|
|
100
100
|
complete -c doing -l case -f -r -n '__fish_doing_using_command again resume' -d Case\ sensitivity\ for\ search\ string\ matching\ \[\(c\)ase-sensitive
|
|
101
101
|
complete -c doing -l editor -s e -f -n '__fish_doing_using_command again resume' -d Edit\ duplicated\ entry\ with\ vim\ before\ adding
|
|
102
|
-
complete -c doing -l fuzzy -f -n '__fish_doing_using_command again resume' -d Use\ alternative\ fuzzy\ matching\ for\ search\ string
|
|
103
102
|
complete -c doing -l interactive -s i -f -n '__fish_doing_using_command again resume' -d Select\ item\ to\ resume\ from\ a\ menu\ of\ matching\ entries
|
|
104
103
|
complete -c doing -l in -f -r -n '__fish_doing_using_command again resume' -d Add\ new\ entry\ to\ section
|
|
105
104
|
complete -c doing -l note -s n -f -r -n '__fish_doing_using_command again resume' -d Note
|
|
@@ -111,7 +110,6 @@ complete -c doing -l exact -s x -f -n '__fish_doing_using_command again resume'
|
|
|
111
110
|
complete -c doing -l before -f -r -n '__fish_doing_using_command archive move' -d Archive\ entries\ older\ than\ date
|
|
112
111
|
complete -c doing -l bool -f -r -n '__fish_doing_using_command archive move' -d Tag\ boolean
|
|
113
112
|
complete -c doing -l case -f -r -n '__fish_doing_using_command archive move' -d Case\ sensitivity\ for\ search\ string\ matching\ \[\(c\)ase-sensitive
|
|
114
|
-
complete -c doing -l fuzzy -f -n '__fish_doing_using_command archive move' -d Use\ alternative\ fuzzy\ matching\ for\ search\ string
|
|
115
113
|
complete -c doing -l keep -s k -f -r -n '__fish_doing_using_command archive move' -d How\ many\ items\ to\ keep
|
|
116
114
|
complete -c doing -l label -f -n '__fish_doing_using_command archive move' -d Label\ moved\ items\ with\ @from\(SECTION_NAME\)
|
|
117
115
|
complete -c doing -l not -f -n '__fish_doing_using_command archive move' -d Show\ items\ that\ \*don\'t\*\ match\ search\ string
|
|
@@ -130,7 +128,6 @@ complete -c doing -l unfinished -s u -f -n '__fish_doing_using_command autotag'
|
|
|
130
128
|
complete -c doing -l archive -s a -f -n '__fish_doing_using_command cancel' -d Archive\ entries
|
|
131
129
|
complete -c doing -l bool -f -r -n '__fish_doing_using_command cancel' -d Boolean
|
|
132
130
|
complete -c doing -l case -f -r -n '__fish_doing_using_command cancel' -d Case\ sensitivity\ for\ search\ string\ matching\ \[\(c\)ase-sensitive
|
|
133
|
-
complete -c doing -l fuzzy -f -n '__fish_doing_using_command cancel' -d Use\ alternative\ fuzzy\ matching\ for\ search\ string
|
|
134
131
|
complete -c doing -l interactive -s i -f -n '__fish_doing_using_command cancel' -d Select\ item\(s\)\ to\ cancel\ from\ a\ menu\ of\ matching\ entries
|
|
135
132
|
complete -c doing -l not -f -n '__fish_doing_using_command cancel' -d Finish\ items\ that\ \*don\'t\*\ match\ search/tag\ filters
|
|
136
133
|
complete -c doing -l section -s s -f -r -n '__fish_doing_using_command cancel' -d Section
|
|
@@ -162,7 +159,6 @@ complete -c doing -l back -s b -f -r -n '__fish_doing_using_command finish' -d B
|
|
|
162
159
|
complete -c doing -l bool -f -r -n '__fish_doing_using_command finish' -d Boolean
|
|
163
160
|
complete -c doing -l case -f -r -n '__fish_doing_using_command finish' -d Case\ sensitivity\ for\ search\ string\ matching\ \[\(c\)ase-sensitive
|
|
164
161
|
complete -c doing -l date -f -n '__fish_doing_using_command finish' -d Include\ date
|
|
165
|
-
complete -c doing -l fuzzy -f -n '__fish_doing_using_command finish' -d Use\ alternative\ fuzzy\ matching\ for\ search\ string
|
|
166
162
|
complete -c doing -l interactive -s i -f -n '__fish_doing_using_command finish' -d Select\ item\(s\)\ to\ finish\ from\ a\ menu\ of\ matching\ entries
|
|
167
163
|
complete -c doing -l not -f -n '__fish_doing_using_command finish' -d Finish\ items\ that\ \*don\'t\*\ match\ search/tag\ filters
|
|
168
164
|
complete -c doing -l remove -s r -f -n '__fish_doing_using_command finish' -d Remove\ done\ tag
|
|
@@ -175,7 +171,6 @@ complete -c doing -l exact -s x -f -n '__fish_doing_using_command finish' -d Fo
|
|
|
175
171
|
complete -c doing -l after -f -r -n '__fish_doing_using_command grep search' -d Constrain\ search\ to\ entries\ newer\ than\ date
|
|
176
172
|
complete -c doing -l before -f -r -n '__fish_doing_using_command grep search' -d Constrain\ search\ to\ entries\ older\ than\ date
|
|
177
173
|
complete -c doing -l case -f -r -n '__fish_doing_using_command grep search' -d Case\ sensitivity\ for\ search\ string\ matching\ \[\(c\)ase-sensitive
|
|
178
|
-
complete -c doing -l fuzzy -f -n '__fish_doing_using_command grep search' -d Use\ alternative\ fuzzy\ matching\ for\ search\ string
|
|
179
174
|
complete -c doing -l interactive -s i -f -n '__fish_doing_using_command grep search' -d Display\ an\ interactive\ menu\ of\ results\ to\ perform\ further\ operations
|
|
180
175
|
complete -c doing -l not -f -n '__fish_doing_using_command grep search' -d Show\ items\ that\ \*don\'t\*\ match\ search\ string
|
|
181
176
|
complete -c doing -l output -s o -f -r -n '__fish_doing_using_command grep search' -d Output\ to\ export\ format
|
|
@@ -191,7 +186,6 @@ complete -c doing -l autotag -f -n '__fish_doing_using_command import' -d Auto
|
|
|
191
186
|
complete -c doing -l before -f -r -n '__fish_doing_using_command import' -d Import\ entries\ older\ than\ date
|
|
192
187
|
complete -c doing -l case -f -r -n '__fish_doing_using_command import' -d Case\ sensitivity\ for\ search\ string\ matching\ \[\(c\)ase-sensitive
|
|
193
188
|
complete -c doing -l from -s f -f -r -n '__fish_doing_using_command import' -d Date\ range\ to\ import
|
|
194
|
-
complete -c doing -l fuzzy -f -n '__fish_doing_using_command import' -d Use\ alternative\ fuzzy\ matching\ for\ search\ string
|
|
195
189
|
complete -c doing -l not -f -n '__fish_doing_using_command import' -d Import\ items\ that\ \*don\'t\*\ match\ search/tag/date\ filters
|
|
196
190
|
complete -c doing -l only_timed -f -n '__fish_doing_using_command import' -d Only\ import\ items\ with\ recorded\ time\ intervals
|
|
197
191
|
complete -c doing -l overlap -f -n '__fish_doing_using_command import' -d Allow\ entries\ that\ overlap\ existing\ times
|
|
@@ -204,7 +198,6 @@ complete -c doing -l exact -s x -f -n '__fish_doing_using_command import' -d Fo
|
|
|
204
198
|
complete -c doing -l bool -f -r -n '__fish_doing_using_command last' -d Tag\ boolean
|
|
205
199
|
complete -c doing -l case -f -r -n '__fish_doing_using_command last' -d Case\ sensitivity\ for\ search\ string\ matching\ \[\(c\)ase-sensitive
|
|
206
200
|
complete -c doing -l editor -s e -f -n '__fish_doing_using_command last' -d Edit\ entry\ with\ vim
|
|
207
|
-
complete -c doing -l fuzzy -f -n '__fish_doing_using_command last' -d Use\ alternative\ fuzzy\ matching\ for\ search\ string
|
|
208
201
|
complete -c doing -l not -f -n '__fish_doing_using_command last' -d Show\ items\ that\ \*don\'t\*\ match\ search\ string\ or\ tag\ filter
|
|
209
202
|
complete -c doing -l section -s s -f -r -n '__fish_doing_using_command last' -d Specify\ a\ section
|
|
210
203
|
complete -c doing -l search -f -r -n '__fish_doing_using_command last' -d Search\ filter
|
|
@@ -218,7 +211,6 @@ complete -c doing -l count -s c -f -r -n '__fish_doing_using_command mark flag'
|
|
|
218
211
|
complete -c doing -l case -f -r -n '__fish_doing_using_command mark flag' -d Case\ sensitivity\ for\ search\ string\ matching\ \[\(c\)ase-sensitive
|
|
219
212
|
complete -c doing -l date -s d -f -n '__fish_doing_using_command mark flag' -d Include\ current\ date/time\ with\ tag
|
|
220
213
|
complete -c doing -l force -f -n '__fish_doing_using_command mark flag' -d Don\'t\ ask\ permission\ to\ flag\ all\ entries\ when\ count\ is\ 0
|
|
221
|
-
complete -c doing -l fuzzy -f -n '__fish_doing_using_command mark flag' -d Use\ alternative\ fuzzy\ matching\ for\ search\ string
|
|
222
214
|
complete -c doing -l interactive -s i -f -n '__fish_doing_using_command mark flag' -d Select\ item\(s\)\ to\ flag\ from\ a\ menu\ of\ matching\ entries
|
|
223
215
|
complete -c doing -l not -f -n '__fish_doing_using_command mark flag' -d Flag\ items\ that\ \*don\'t\*\ match\ search/tag/date\ filters
|
|
224
216
|
complete -c doing -l remove -s r -f -n '__fish_doing_using_command mark flag' -d Remove\ flag
|
|
@@ -235,7 +227,6 @@ complete -c doing -l section -s s -f -r -n '__fish_doing_using_command meanwhile
|
|
|
235
227
|
complete -c doing -l bool -f -r -n '__fish_doing_using_command note' -d Boolean
|
|
236
228
|
complete -c doing -l case -f -r -n '__fish_doing_using_command note' -d Case\ sensitivity\ for\ search\ string\ matching\ \[\(c\)ase-sensitive
|
|
237
229
|
complete -c doing -l editor -s e -f -n '__fish_doing_using_command note' -d Edit\ entry\ with\ vim
|
|
238
|
-
complete -c doing -l fuzzy -f -n '__fish_doing_using_command note' -d Use\ alternative\ fuzzy\ matching\ for\ search\ string
|
|
239
230
|
complete -c doing -l interactive -s i -f -n '__fish_doing_using_command note' -d Select\ item\ for\ new\ note\ from\ a\ menu\ of\ matching\ entries
|
|
240
231
|
complete -c doing -l not -f -n '__fish_doing_using_command note' -d Add\ note\ to\ item\ that\ \*doesn\'t\*\ match\ search/tag\ filters
|
|
241
232
|
complete -c doing -l remove -s r -f -n '__fish_doing_using_command note' -d Replace/Remove\ last\ entry\'s\ note
|
|
@@ -264,7 +255,6 @@ complete -c doing -l tag_sort -f -r -n '__fish_doing_using_command recent' -d S
|
|
|
264
255
|
complete -c doing -l totals -f -n '__fish_doing_using_command recent' -d Show\ intervals\ with\ totals\ at\ the\ end\ of\ output
|
|
265
256
|
complete -c doing -l bool -f -r -n '__fish_doing_using_command reset begin' -d Boolean
|
|
266
257
|
complete -c doing -l case -f -r -n '__fish_doing_using_command reset begin' -d Case\ sensitivity\ for\ search\ string\ matching\ \[\(c\)ase-sensitive
|
|
267
|
-
complete -c doing -l fuzzy -f -n '__fish_doing_using_command reset begin' -d Use\ alternative\ fuzzy\ matching\ for\ search\ string
|
|
268
258
|
complete -c doing -l interactive -s i -f -n '__fish_doing_using_command reset begin' -d Select\ from\ a\ menu\ of\ matching\ entries
|
|
269
259
|
complete -c doing -l not -f -n '__fish_doing_using_command reset begin' -d Reset\ items\ that\ \*don\'t\*\ match\ search/tag\ filters
|
|
270
260
|
complete -c doing -l resume -s r -f -n '__fish_doing_using_command reset begin' -d Resume\ entry
|
|
@@ -275,7 +265,6 @@ complete -c doing -l exact -s x -f -n '__fish_doing_using_command reset begin'
|
|
|
275
265
|
complete -c doing -l before -f -r -n '__fish_doing_using_command rotate' -d Rotate\ entries\ older\ than\ date
|
|
276
266
|
complete -c doing -l bool -f -r -n '__fish_doing_using_command rotate' -d Tag\ boolean
|
|
277
267
|
complete -c doing -l case -f -r -n '__fish_doing_using_command rotate' -d Case\ sensitivity\ for\ search\ string\ matching\ \[\(c\)ase-sensitive
|
|
278
|
-
complete -c doing -l fuzzy -f -n '__fish_doing_using_command rotate' -d Use\ alternative\ fuzzy\ matching\ for\ search\ string
|
|
279
268
|
complete -c doing -l keep -s k -f -r -n '__fish_doing_using_command rotate' -d How\ many\ items\ to\ keep\ in\ each\ section
|
|
280
269
|
complete -c doing -l not -f -n '__fish_doing_using_command rotate' -d Rotate\ items\ that\ \*don\'t\*\ match\ search\ string\ or\ tag\ filter
|
|
281
270
|
complete -c doing -l section -s s -f -r -n '__fish_doing_using_command rotate' -d Section\ to\ rotate
|
|
@@ -309,7 +298,6 @@ complete -c doing -l before -f -r -n '__fish_doing_using_command show' -d View\
|
|
|
309
298
|
complete -c doing -l count -s c -f -r -n '__fish_doing_using_command show' -d Max\ count\ to\ show
|
|
310
299
|
complete -c doing -l case -f -r -n '__fish_doing_using_command show' -d Case\ sensitivity\ for\ search\ string\ matching\ \[\(c\)ase-sensitive
|
|
311
300
|
complete -c doing -l from -s f -f -r -n '__fish_doing_using_command show' -d Date\ range\ to\ show
|
|
312
|
-
complete -c doing -l fuzzy -f -n '__fish_doing_using_command show' -d Use\ alternative\ fuzzy\ matching\ for\ search\ string
|
|
313
301
|
complete -c doing -l interactive -s i -f -n '__fish_doing_using_command show' -d Select\ from\ a\ menu\ of\ matching\ entries\ to\ perform\ additional\ operations
|
|
314
302
|
complete -c doing -l not -f -n '__fish_doing_using_command show' -d Show\ items\ that\ \*don\'t\*\ match\ search/tag/date\ filters
|
|
315
303
|
complete -c doing -l output -s o -f -r -n '__fish_doing_using_command show' -d Output\ to\ export\ format
|
|
@@ -333,7 +321,6 @@ complete -c doing -l count -s c -f -r -n '__fish_doing_using_command tag' -d How
|
|
|
333
321
|
complete -c doing -l case -f -r -n '__fish_doing_using_command tag' -d Case\ sensitivity\ for\ search\ string\ matching\ \[\(c\)ase-sensitive
|
|
334
322
|
complete -c doing -l date -s d -f -n '__fish_doing_using_command tag' -d Include\ current\ date/time\ with\ tag
|
|
335
323
|
complete -c doing -l force -f -n '__fish_doing_using_command tag' -d Don\'t\ ask\ permission\ to\ tag\ all\ entries\ when\ count\ is\ 0
|
|
336
|
-
complete -c doing -l fuzzy -f -n '__fish_doing_using_command tag' -d Use\ alternative\ fuzzy\ matching\ for\ search\ string
|
|
337
324
|
complete -c doing -l interactive -s i -f -n '__fish_doing_using_command tag' -d Select\ item\(s\)\ to\ tag\ from\ a\ menu\ of\ matching\ entries
|
|
338
325
|
complete -c doing -l not -f -n '__fish_doing_using_command tag' -d Tag\ items\ that\ \*don\'t\*\ match\ search/tag\ filters
|
|
339
326
|
complete -c doing -l remove -s r -f -n '__fish_doing_using_command tag' -d Remove\ given\ tag\(s\)
|
|
@@ -359,7 +346,6 @@ complete -c doing -l before -f -r -n '__fish_doing_using_command view' -d View\
|
|
|
359
346
|
complete -c doing -l count -s c -f -r -n '__fish_doing_using_command view' -d Count\ to\ display
|
|
360
347
|
complete -c doing -l case -f -r -n '__fish_doing_using_command view' -d Case\ sensitivity\ for\ search\ string\ matching\ \[\(c\)ase-sensitive
|
|
361
348
|
complete -c doing -l color -f -n '__fish_doing_using_command view' -d Include\ colors\ in\ output
|
|
362
|
-
complete -c doing -l fuzzy -f -n '__fish_doing_using_command view' -d Use\ alternative\ fuzzy\ matching\ for\ search\ string
|
|
363
349
|
complete -c doing -l interactive -s i -f -n '__fish_doing_using_command view' -d Select\ from\ a\ menu\ of\ matching\ entries\ to\ perform\ additional\ operations
|
|
364
350
|
complete -c doing -l not -f -n '__fish_doing_using_command view' -d Show\ items\ that\ \*don\'t\*\ match\ search\ string
|
|
365
351
|
complete -c doing -l output -s o -f -r -n '__fish_doing_using_command view' -d Output\ to\ export\ format
|
data/lib/doing/cli_status.rb
CHANGED
|
@@ -14,8 +14,12 @@ module Status
|
|
|
14
14
|
$stderr.print format("#{esc['kill']}#{esc['boldyellow']}> #{esc['boldgreen']}%s #{esc['white']}[#{esc['boldwhite']}%#{@commands.count.to_s.length}d#{esc['boldblack']}/#{esc['boldyellow']}%d#{esc['white']}]: #{esc['boldcyan']}%s#{esc['default']}\r", msg, idx, total, tail)
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
-
def status(msg, reset: true)
|
|
18
|
-
$stderr.print format("#{esc['kill']}#{esc['boldyellow']}> #{esc['whiteboard']}%s#{esc['default']}%s", msg, reset ? "\r" :
|
|
17
|
+
def status(msg, reset: true, end_char: "\n")
|
|
18
|
+
$stderr.print format("#{esc['kill']}#{esc['boldyellow']}> #{esc['whiteboard']}%s#{esc['default']}%s", msg, reset ? "\r" : end_char)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def msg(msg, reset: true, color: 'green', end_char: "\n")
|
|
22
|
+
$stderr.print format("#{esc['kill']}#{esc[color]}%s#{esc['default']}%s", msg, reset ? "\r" : end_char)
|
|
19
23
|
end
|
|
20
24
|
|
|
21
25
|
def clear
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
module Doing
|
|
2
|
+
module Completion
|
|
3
|
+
class BashCompletions
|
|
4
|
+
attr_accessor :commands, :global_options
|
|
5
|
+
|
|
6
|
+
def main_function
|
|
7
|
+
first = true
|
|
8
|
+
out = []
|
|
9
|
+
logic = []
|
|
10
|
+
need_export = []
|
|
11
|
+
|
|
12
|
+
@commands.each_with_index do |cmd, i|
|
|
13
|
+
@bar.advance
|
|
14
|
+
|
|
15
|
+
data = get_help_sections(cmd[:commands].first)
|
|
16
|
+
|
|
17
|
+
arg = data[:synopsis].join(' ').strip.split(/ /).last
|
|
18
|
+
case arg
|
|
19
|
+
when /(path|file)/i
|
|
20
|
+
type = :file
|
|
21
|
+
when /sect/i
|
|
22
|
+
type = 'sections'
|
|
23
|
+
when /view/i
|
|
24
|
+
type = 'views'
|
|
25
|
+
else
|
|
26
|
+
type = nil
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
if data[:command_options]
|
|
30
|
+
options = parse_options(data[:command_options])
|
|
31
|
+
out << command_function(cmd[:commands].first, options, type)
|
|
32
|
+
|
|
33
|
+
if first
|
|
34
|
+
op = 'if'
|
|
35
|
+
first = false
|
|
36
|
+
else
|
|
37
|
+
op = 'elif'
|
|
38
|
+
end
|
|
39
|
+
logic << %(#{op} [[ $last =~ (#{cmd[:commands].join('|')}) ]]; then _doing_#{cmd[:commands].first})
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
out << <<~EOFUNC
|
|
44
|
+
_doing()
|
|
45
|
+
{
|
|
46
|
+
local last="${@: -1}"
|
|
47
|
+
local token=${COMP_WORDS[$COMP_CWORD]}
|
|
48
|
+
|
|
49
|
+
#{logic.join("\n ")}
|
|
50
|
+
else
|
|
51
|
+
OLD_IFS="$IFS"
|
|
52
|
+
IFS=$'\n'
|
|
53
|
+
COMPREPLY=( $(compgen -W "$(doing help -c)" -- $token) )
|
|
54
|
+
IFS="$OLD_IFS"
|
|
55
|
+
fi
|
|
56
|
+
}
|
|
57
|
+
EOFUNC
|
|
58
|
+
out.join("\n")
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def command_function(command, options, type)
|
|
62
|
+
long_options = []
|
|
63
|
+
short_options = []
|
|
64
|
+
|
|
65
|
+
options.each do |o|
|
|
66
|
+
next if o.nil?
|
|
67
|
+
|
|
68
|
+
long_options << o[:long] if o[:long]
|
|
69
|
+
short_options << o[:short] if o[:short]
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
long = long_options.map! {|o| "--#{o}"}.join(' ')
|
|
73
|
+
short = short_options.map! {|o| "-#{o}"}.join(' ')
|
|
74
|
+
words = ''
|
|
75
|
+
logic = ''
|
|
76
|
+
words, logic = get_words(type) if type && type.is_a?(String)
|
|
77
|
+
|
|
78
|
+
func = <<~ENDFUNC
|
|
79
|
+
_doing_#{command}() {
|
|
80
|
+
#{words}
|
|
81
|
+
if [[ "$token" == --* ]]; then
|
|
82
|
+
COMPREPLY=( $( compgen -W '#{long}' -- $token ) )
|
|
83
|
+
elif [[ "$token" == -* ]]; then
|
|
84
|
+
COMPREPLY=( $( compgen -W '#{short} #{long}' -- $token ) )
|
|
85
|
+
#{logic}
|
|
86
|
+
fi
|
|
87
|
+
}
|
|
88
|
+
ENDFUNC
|
|
89
|
+
|
|
90
|
+
func
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def get_words(type)
|
|
94
|
+
func = <<~EOFUNC
|
|
95
|
+
OLD_IFS="$IFS"
|
|
96
|
+
local token=${COMP_WORDS[$COMP_CWORD]}
|
|
97
|
+
IFS=$'\t'
|
|
98
|
+
local words=$(doing #{type})
|
|
99
|
+
IFS="$OLD_IFS"
|
|
100
|
+
EOFUNC
|
|
101
|
+
|
|
102
|
+
logic = <<~EOLOGIC
|
|
103
|
+
else
|
|
104
|
+
local nocasematchWasOff=0
|
|
105
|
+
shopt nocasematch >/dev/null || nocasematchWasOff=1
|
|
106
|
+
(( nocasematchWasOff )) && shopt -s nocasematch
|
|
107
|
+
local w matches=()
|
|
108
|
+
OLD_IFS="$IFS"
|
|
109
|
+
IFS=$'\t'‰
|
|
110
|
+
for w in $words; do
|
|
111
|
+
if [[ "$w" == "$token"* ]]; then
|
|
112
|
+
matches+=("${w// /\ }")
|
|
113
|
+
fi
|
|
114
|
+
done
|
|
115
|
+
IFS="$OLD_IFS"
|
|
116
|
+
(( nocasematchWasOff )) && shopt -u nocasematch
|
|
117
|
+
COMPREPLY=("${matches[@]}")
|
|
118
|
+
EOLOGIC
|
|
119
|
+
|
|
120
|
+
[func, logic]
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def get_help_sections(command = '')
|
|
126
|
+
res = `doing help #{command}`.strip
|
|
127
|
+
scanned = res.scan(/(?m-i)^([A-Z ]+)\n([\s\S]*?)(?=\n+[A-Z]+|\Z)/)
|
|
128
|
+
sections = {}
|
|
129
|
+
scanned.each do |sect|
|
|
130
|
+
title = sect[0].downcase.strip.gsub(/ +/, '_').to_sym
|
|
131
|
+
content = sect[1].split(/\n/).map(&:strip).delete_if(&:empty?)
|
|
132
|
+
sections[title] = content
|
|
133
|
+
end
|
|
134
|
+
sections
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
def parse_option(option)
|
|
138
|
+
res = option.match(/(?:-(?<short>\w), )?(?:--(?:\[no-\])?(?<long>[\w_]+)(?:=(?<arg>\w+))?)\s+- (?<desc>.*?)$/)
|
|
139
|
+
return nil unless res
|
|
140
|
+
{
|
|
141
|
+
short: res['short'],
|
|
142
|
+
long: res['long'],
|
|
143
|
+
arg: res[:arg],
|
|
144
|
+
description: res['desc'].short_desc
|
|
145
|
+
}
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
def parse_options(options)
|
|
149
|
+
options.map { |opt| parse_option(opt) }
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
def parse_command(command)
|
|
153
|
+
res = command.match(/^(?<cmd>[^, \t]+)(?<alias>(?:, [^, \t]+)*)?\s+- (?<desc>.*?)$/)
|
|
154
|
+
commands = [res['cmd']]
|
|
155
|
+
commands.concat(res['alias'].split(/, /).delete_if(&:empty?)) if res['alias']
|
|
156
|
+
|
|
157
|
+
{
|
|
158
|
+
commands: commands,
|
|
159
|
+
description: res['desc'].short_desc
|
|
160
|
+
}
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
def parse_commands(commands)
|
|
164
|
+
commands.map { |cmd| parse_command(cmd) }
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
def initialize
|
|
168
|
+
data = get_help_sections
|
|
169
|
+
@global_options = parse_options(data[:global_options])
|
|
170
|
+
@commands = parse_commands(data[:commands])
|
|
171
|
+
@bar = TTY::ProgressBar.new("\033[0;0;33mGenerating Bash completions: \033[0;35;40m[:bar]\033[0m", total: @commands.count, bar_format: :blade)
|
|
172
|
+
@bar.resize(25)
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
def generate_completions
|
|
176
|
+
@bar.start
|
|
177
|
+
out = []
|
|
178
|
+
out << main_function
|
|
179
|
+
out << 'complete -F _doing doing'
|
|
180
|
+
@bar.finish
|
|
181
|
+
out.join("\n")
|
|
182
|
+
end
|
|
183
|
+
end
|
|
184
|
+
end
|
|
185
|
+
end
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
module Doing
|
|
2
|
+
module Completion
|
|
3
|
+
class FishCompletions
|
|
4
|
+
|
|
5
|
+
attr_accessor :commands, :global_options
|
|
6
|
+
|
|
7
|
+
def generate_helpers
|
|
8
|
+
<<~EOFUNCTIONS
|
|
9
|
+
function __fish_doing_needs_command
|
|
10
|
+
# Figure out if the current invocation already has a command.
|
|
11
|
+
|
|
12
|
+
set -l opts h-help config_file= f-doing_file= n-notes v-version stdout d-debug default x-noauto
|
|
13
|
+
set cmd (commandline -opc)
|
|
14
|
+
set -e cmd[1]
|
|
15
|
+
argparse -s $opts -- $cmd 2>/dev/null
|
|
16
|
+
or return 0
|
|
17
|
+
# These flags function as commands, effectively.
|
|
18
|
+
if set -q argv[1]
|
|
19
|
+
# Also print the command, so this can be used to figure out what it is.
|
|
20
|
+
echo $argv[1]
|
|
21
|
+
return 1
|
|
22
|
+
end
|
|
23
|
+
return 0
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
function __fish_doing_using_command
|
|
27
|
+
set -l cmd (__fish_doing_needs_command)
|
|
28
|
+
test -z "$cmd"
|
|
29
|
+
and return 1
|
|
30
|
+
contains -- $cmd $argv
|
|
31
|
+
and return 0
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
function __fish_doing_complete_sections
|
|
35
|
+
doing sections -c
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
function __fish_doing_complete_views
|
|
39
|
+
doing views -c
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
function __fish_doing_subcommands
|
|
43
|
+
doing help -c
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
function __fish_doing_export_plugins
|
|
47
|
+
doing plugins --type export -c
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
function __fish_doing_import_plugins
|
|
51
|
+
doing plugins --type import -c
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
function __fish_doing_complete_templates
|
|
55
|
+
doing template -c
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
complete -c doing -f
|
|
59
|
+
complete -xc doing -n '__fish_doing_needs_command' -a '(__fish_doing_subcommands)'
|
|
60
|
+
|
|
61
|
+
complete -f -c doing -n '__fish_doing_using_command show' -a '(__fish_doing_complete_sections)'
|
|
62
|
+
complete -f -c doing -n '__fish_doing_using_command view' -a '(__fish_doing_complete_views)'
|
|
63
|
+
complete -f -c doing -n '__fish_doing_using_command template' -a '(__fish_doing_complete_templates)'
|
|
64
|
+
complete -f -c doing -s t -l type -x -n '__fish_doing_using_command import' -a '(__fish_doing_import_plugins)'
|
|
65
|
+
|
|
66
|
+
complete -xc doing -n '__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from (doing help -c)' -a "(doing help -c)"
|
|
67
|
+
EOFUNCTIONS
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def get_help_sections(command = '')
|
|
71
|
+
res = `doing help #{command}`.strip
|
|
72
|
+
scanned = res.scan(/(?m-i)^([A-Z ]+)\n([\s\S]*?)(?=\n+[A-Z]+|\Z)/)
|
|
73
|
+
sections = {}
|
|
74
|
+
scanned.each do |sect|
|
|
75
|
+
title = sect[0].downcase.strip.gsub(/ +/, '_').to_sym
|
|
76
|
+
content = sect[1].split(/\n/).map(&:strip).delete_if(&:empty?)
|
|
77
|
+
sections[title] = content
|
|
78
|
+
end
|
|
79
|
+
sections
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def parse_option(option)
|
|
83
|
+
res = option.match(/(?:-(?<short>\w), )?(?:--(?:\[no-\])?(?<long>[\w_]+)(?:=(?<arg>\w+))?)\s+- (?<desc>.*?)$/)
|
|
84
|
+
return nil unless res
|
|
85
|
+
{
|
|
86
|
+
short: res['short'],
|
|
87
|
+
long: res['long'],
|
|
88
|
+
arg: res[:arg],
|
|
89
|
+
description: res['desc'].short_desc
|
|
90
|
+
}
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def parse_options(options)
|
|
94
|
+
options.map { |opt| parse_option(opt) }
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def parse_command(command)
|
|
98
|
+
res = command.match(/^(?<cmd>[^, \t]+)(?<alias>(?:, [^, \t]+)*)?\s+- (?<desc>.*?)$/)
|
|
99
|
+
commands = [res['cmd']]
|
|
100
|
+
commands.concat(res['alias'].split(/, /).delete_if(&:empty?)) if res['alias']
|
|
101
|
+
|
|
102
|
+
{
|
|
103
|
+
commands: commands,
|
|
104
|
+
description: res['desc'].short_desc
|
|
105
|
+
}
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def parse_commands(commands)
|
|
109
|
+
commands.map { |cmd| parse_command(cmd) }
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def generate_subcommand_completions
|
|
113
|
+
out = []
|
|
114
|
+
@commands.each_with_index do |cmd, i|
|
|
115
|
+
out << "complete -xc doing -n '__fish_doing_needs_command' -a '#{cmd[:commands].join(' ')}' -d #{Shellwords.escape(cmd[:description])}"
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
out.join("\n")
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def generate_subcommand_option_completions
|
|
122
|
+
|
|
123
|
+
out = []
|
|
124
|
+
need_export = []
|
|
125
|
+
|
|
126
|
+
@commands.each_with_index do |cmd, i|
|
|
127
|
+
@bar.advance
|
|
128
|
+
data = get_help_sections(cmd[:commands].first)
|
|
129
|
+
|
|
130
|
+
if data[:synopsis].join(' ').strip.split(/ /).last =~ /(path|file)/i
|
|
131
|
+
out << "complete -c doing -F -n '__fish_doing_using_command #{cmd[:commands].join(" ")}'"
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
if data[:command_options]
|
|
135
|
+
parse_options(data[:command_options]).each do |option|
|
|
136
|
+
next if option.nil?
|
|
137
|
+
|
|
138
|
+
arg = option[:arg] ? '-r' : ''
|
|
139
|
+
short = option[:short] ? "-s #{option[:short]}" : ''
|
|
140
|
+
long = option[:long] ? "-l #{option[:long]}" : ''
|
|
141
|
+
out << "complete -c doing #{long} #{short} -f #{arg} -n '__fish_doing_using_command #{cmd[:commands].join(' ')}' -d #{Shellwords.escape(option[:description])}"
|
|
142
|
+
|
|
143
|
+
need_export.concat(cmd[:commands]) if option[:long] == 'output'
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
unless need_export.empty?
|
|
149
|
+
out << "complete -f -c doing -s o -l output -x -n '__fish_doing_using_command #{need_export.join(' ')}' -a '(__fish_doing_export_plugins)'"
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
# clear
|
|
153
|
+
out.join("\n")
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
def initialize
|
|
157
|
+
data = get_help_sections
|
|
158
|
+
@global_options = parse_options(data[:global_options])
|
|
159
|
+
@commands = parse_commands(data[:commands])
|
|
160
|
+
@bar = TTY::ProgressBar.new("\033[0;0;33mGenerating Fish completions: \033[0;35;40m[:bar]\033[0m", total: @commands.count, bar_format: :blade)
|
|
161
|
+
@bar.resize(25)
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
def generate_completions
|
|
165
|
+
@bar.start
|
|
166
|
+
out = []
|
|
167
|
+
out << generate_helpers
|
|
168
|
+
out << generate_subcommand_completions
|
|
169
|
+
out << generate_subcommand_option_completions
|
|
170
|
+
@bar.finish
|
|
171
|
+
out.join("\n")
|
|
172
|
+
end
|
|
173
|
+
end
|
|
174
|
+
end
|
|
175
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
class ::String
|
|
2
|
+
def short_desc
|
|
3
|
+
split(/[,.]/)[0].sub(/ \(.*?\)?$/, '').strip
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
def ltrunc(max)
|
|
7
|
+
if length > max
|
|
8
|
+
sub(/^.*?(.{#{max - 3}})$/, '...\1')
|
|
9
|
+
else
|
|
10
|
+
self
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def ltrunc!(max)
|
|
15
|
+
replace ltrunc(max)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
module Doing
|
|
2
|
+
module Completion
|
|
3
|
+
class ZshCompletions
|
|
4
|
+
|
|
5
|
+
attr_accessor :commands, :global_options
|
|
6
|
+
|
|
7
|
+
def generate_helpers
|
|
8
|
+
out=<<~EOFUNCTIONS
|
|
9
|
+
compdef _doing doing
|
|
10
|
+
|
|
11
|
+
function _doing() {
|
|
12
|
+
local line state
|
|
13
|
+
|
|
14
|
+
function _commands {
|
|
15
|
+
local -a commands
|
|
16
|
+
|
|
17
|
+
commands=(
|
|
18
|
+
#{generate_subcommand_completions.join("\n ")}
|
|
19
|
+
)
|
|
20
|
+
_describe 'command' commands
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
_arguments -C \
|
|
24
|
+
"1: :_commands" \
|
|
25
|
+
"*::arg:->args"
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
case $line[1] in
|
|
30
|
+
#{generate_subcommand_option_completions(indent: ' ').join("\n ")}
|
|
31
|
+
esac
|
|
32
|
+
|
|
33
|
+
_arguments -s $args
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
EOFUNCTIONS
|
|
37
|
+
@bar.finish
|
|
38
|
+
out
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def get_help_sections(command = '')
|
|
42
|
+
res = `doing help #{command}`.strip
|
|
43
|
+
scanned = res.scan(/(?m-i)^([A-Z ]+)\n([\s\S]*?)(?=\n+[A-Z]+|\Z)/)
|
|
44
|
+
sections = {}
|
|
45
|
+
scanned.each do |sect|
|
|
46
|
+
title = sect[0].downcase.strip.gsub(/ +/, '_').to_sym
|
|
47
|
+
content = sect[1].split(/\n/).map(&:strip).delete_if(&:empty?)
|
|
48
|
+
sections[title] = content
|
|
49
|
+
end
|
|
50
|
+
sections
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def parse_option(option)
|
|
54
|
+
res = option.match(/(?:-(?<short>\w), )?(?:--(?:\[no-\])?(?<long>[\w_]+)(?:=(?<arg>\w+))?)\s+- (?<desc>.*?)$/)
|
|
55
|
+
return nil unless res
|
|
56
|
+
|
|
57
|
+
{
|
|
58
|
+
short: res['short'],
|
|
59
|
+
long: res['long'],
|
|
60
|
+
arg: res[:arg],
|
|
61
|
+
description: res['desc'].short_desc
|
|
62
|
+
}
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def parse_options(options)
|
|
66
|
+
options.map { |opt| parse_option(opt) }
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def parse_command(command)
|
|
70
|
+
res = command.match(/^(?<cmd>[^, \t]+)(?<alias>(?:, [^, \t]+)*)?\s+- (?<desc>.*?)$/)
|
|
71
|
+
commands = [res['cmd']]
|
|
72
|
+
commands.concat(res['alias'].split(/, /).delete_if(&:empty?)) if res['alias']
|
|
73
|
+
|
|
74
|
+
{
|
|
75
|
+
commands: commands,
|
|
76
|
+
description: res['desc'].short_desc
|
|
77
|
+
}
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def parse_commands(commands)
|
|
81
|
+
commands.map { |cmd| parse_command(cmd) }
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def generate_subcommand_completions
|
|
85
|
+
out = []
|
|
86
|
+
@commands.each_with_index do |cmd, i|
|
|
87
|
+
cmd[:commands].each do |c|
|
|
88
|
+
out << "'#{c}:#{cmd[:description].gsub(/'/, '\\\'')}'"
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
out
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def generate_subcommand_option_completions(indent: ' ')
|
|
95
|
+
|
|
96
|
+
out = []
|
|
97
|
+
|
|
98
|
+
@commands.each_with_index do |cmd, i|
|
|
99
|
+
@bar.advance
|
|
100
|
+
|
|
101
|
+
data = get_help_sections(cmd[:commands].first)
|
|
102
|
+
option_arr = []
|
|
103
|
+
|
|
104
|
+
if data[:command_options]
|
|
105
|
+
parse_options(data[:command_options]).each do |option|
|
|
106
|
+
next if option.nil?
|
|
107
|
+
|
|
108
|
+
arg = option[:arg] ? '=' : ''
|
|
109
|
+
|
|
110
|
+
option_arr << if option[:short]
|
|
111
|
+
%({-#{option[:short]},--#{option[:long]}#{arg}}"[#{option[:description].gsub(/'/, '\\\'')}]")
|
|
112
|
+
else
|
|
113
|
+
%("(--#{option[:long]}#{arg})--#{option[:long]}#{arg}}[#{option[:description].gsub(/'/, '\\\'')}]")
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
cmd[:commands].each do |c|
|
|
119
|
+
out << "#{c}) \n#{indent} args=( #{option_arr.join(' ')} )\n#{indent};;"
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
out
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
def initialize
|
|
127
|
+
data = get_help_sections
|
|
128
|
+
@global_options = parse_options(data[:global_options])
|
|
129
|
+
@commands = parse_commands(data[:commands])
|
|
130
|
+
@bar = TTY::ProgressBar.new(" \033[0;0;33mGenerating Zsh completions: \033[0;35;40m[:bar]\033[0m", total: @commands.count, bar_format: :blade)
|
|
131
|
+
@bar.resize(25)
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
def generate_completions
|
|
135
|
+
@bar.start
|
|
136
|
+
generate_helpers
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
end
|