markdown_exec 1.1.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.reek +26 -0
- data/.rubocop.yml +18 -0
- data/CHANGELOG.md +91 -4
- data/Gemfile +1 -0
- data/Gemfile.lock +7 -1
- data/README.md +45 -38
- data/Rakefile +465 -11
- data/bin/tab_completion.sh +16 -36
- data/lib/colorize.rb +64 -0
- data/lib/env.rb +37 -0
- data/lib/globfiles.rb +40 -0
- data/lib/markdown_exec/version.rb +3 -1
- data/lib/markdown_exec.rb +542 -660
- data/lib/menu.yml +293 -0
- data/lib/shared.rb +16 -97
- data/lib/tap.rb +42 -0
- metadata +17 -3
data/Rakefile
CHANGED
@@ -5,8 +5,6 @@ require 'rake/testtask'
|
|
5
5
|
require 'erb'
|
6
6
|
require 'yaml'
|
7
7
|
|
8
|
-
require_relative 'lib/shared'
|
9
|
-
|
10
8
|
Rake::TestTask.new(:test) do |task|
|
11
9
|
task.libs << 'test'
|
12
10
|
task.libs << 'lib'
|
@@ -15,6 +13,13 @@ end
|
|
15
13
|
|
16
14
|
require 'rubocop/rake_task'
|
17
15
|
|
16
|
+
require_relative 'lib/markdown_exec/version'
|
17
|
+
require_relative 'lib/shared'
|
18
|
+
require_relative 'lib/tap'
|
19
|
+
|
20
|
+
include Tap
|
21
|
+
tap_config envvar: MarkdownExec::TAP_DEBUG
|
22
|
+
|
18
23
|
RuboCop::RakeTask.new do |task|
|
19
24
|
task.requires << 'rubocop-minitest'
|
20
25
|
end
|
@@ -24,14 +29,14 @@ task :rubocopminitest do
|
|
24
29
|
`rubocop --require rubocop-minitest`
|
25
30
|
end
|
26
31
|
|
27
|
-
|
28
|
-
|
29
|
-
task default: %i[test rubocop rubocopminitest]
|
32
|
+
task default: %i[test reek rubocop rubocopminitest]
|
30
33
|
|
31
34
|
# task :default => :build
|
32
35
|
|
33
36
|
desc 'gem build'
|
34
37
|
task :build do
|
38
|
+
Rake::Task['update_menu_yml'].execute
|
39
|
+
Rake::Task['update_tab_completion'].execute # after updated menu is readable
|
35
40
|
system "gem build #{MarkdownExec::GEM_NAME}.gemspec"
|
36
41
|
end
|
37
42
|
|
@@ -55,22 +60,462 @@ task :clean do
|
|
55
60
|
system 'rm *.gem'
|
56
61
|
end
|
57
62
|
|
63
|
+
desc 'reek'
|
64
|
+
task :reek do
|
65
|
+
`reek --config .reek .`
|
66
|
+
end
|
67
|
+
|
58
68
|
private
|
59
69
|
|
60
|
-
|
70
|
+
# write menu.yml
|
71
|
+
#
|
72
|
+
desc 'update menu.yml'
|
73
|
+
task :update_menu_yml do
|
74
|
+
menu_options = [
|
61
75
|
|
76
|
+
## priority options
|
77
|
+
#
|
78
|
+
{
|
79
|
+
arg_name: 'NAME',
|
80
|
+
compreply: false,
|
81
|
+
description: 'Name of block',
|
82
|
+
env_var: 'MDE_BLOCK_NAME',
|
83
|
+
long_name: 'block-name',
|
84
|
+
opt_name: 'block_name',
|
85
|
+
short_name: 'b',
|
86
|
+
proc1: 'val_as_str'
|
87
|
+
},
|
88
|
+
{
|
89
|
+
arg_name: 'PATH',
|
90
|
+
default: '.',
|
91
|
+
description: 'Read configuration file',
|
92
|
+
long_name: 'config',
|
93
|
+
proc1: 'path'
|
94
|
+
},
|
95
|
+
{
|
96
|
+
arg_name: 'BOOL',
|
97
|
+
default: false,
|
98
|
+
description: 'Debug output',
|
99
|
+
env_var: MarkdownExec::TAP_DEBUG,
|
100
|
+
long_name: 'debug',
|
101
|
+
short_name: 'd',
|
102
|
+
proc1: 'debug'
|
103
|
+
},
|
104
|
+
{
|
105
|
+
arg_name: 'RELATIVE_PATH',
|
106
|
+
compreply: '.',
|
107
|
+
description: 'Name of document',
|
108
|
+
env_var: 'MDE_FILENAME',
|
109
|
+
long_name: 'filename',
|
110
|
+
opt_name: 'filename',
|
111
|
+
short_name: 'f',
|
112
|
+
proc1: 'val_as_str'
|
113
|
+
},
|
114
|
+
{
|
115
|
+
description: 'App help',
|
116
|
+
long_name: 'help',
|
117
|
+
short_name: 'h',
|
118
|
+
proc1: 'help'
|
119
|
+
},
|
120
|
+
{
|
121
|
+
arg_name: 'RELATIVE_PATH',
|
122
|
+
default: '.',
|
123
|
+
description: 'Path to documents',
|
124
|
+
env_var: 'MDE_PATH',
|
125
|
+
long_name: 'path',
|
126
|
+
opt_name: 'path',
|
127
|
+
short_name: 'p',
|
128
|
+
proc1: 'val_as_str'
|
129
|
+
},
|
130
|
+
{
|
131
|
+
arg_name: 'BOOL',
|
132
|
+
default: true,
|
133
|
+
description: 'Pause for user to approve script',
|
134
|
+
env_var: 'MDE_USER_MUST_APPROVE',
|
135
|
+
long_name: 'user-must-approve',
|
136
|
+
opt_name: 'user_must_approve',
|
137
|
+
short_name: 'q',
|
138
|
+
proc1: 'val_as_bool'
|
139
|
+
},
|
140
|
+
{
|
141
|
+
description: "Print the gem's version",
|
142
|
+
long_name: 'version',
|
143
|
+
short_name: 'v',
|
144
|
+
proc1: 'version'
|
145
|
+
},
|
146
|
+
{
|
147
|
+
description: 'Exit app',
|
148
|
+
long_name: 'exit',
|
149
|
+
short_name: 'x',
|
150
|
+
proc1: 'exit' # ->(_) { exit }
|
151
|
+
},
|
152
|
+
{
|
153
|
+
description: 'Show current configuration values',
|
154
|
+
short_name: '0',
|
155
|
+
proc1: 'show_config'
|
156
|
+
},
|
157
|
+
|
158
|
+
## commands
|
159
|
+
#
|
160
|
+
{
|
161
|
+
description: 'List blocks',
|
162
|
+
long_name: 'list-blocks',
|
163
|
+
opt_name: 'list_blocks',
|
164
|
+
proc1: 'val_as_bool'
|
165
|
+
},
|
166
|
+
{
|
167
|
+
description: 'List default configuration as environment variables',
|
168
|
+
long_name: 'list-default-env',
|
169
|
+
opt_name: 'list_default_env'
|
170
|
+
},
|
171
|
+
{
|
172
|
+
description: 'List default configuration as YAML',
|
173
|
+
long_name: 'list-default-yaml',
|
174
|
+
opt_name: 'list_default_yaml'
|
175
|
+
},
|
176
|
+
{
|
177
|
+
description: 'List docs in current folder',
|
178
|
+
long_name: 'list-docs',
|
179
|
+
opt_name: 'list_docs',
|
180
|
+
proc1: 'val_as_bool'
|
181
|
+
},
|
182
|
+
{
|
183
|
+
description: 'List recent saved output',
|
184
|
+
long_name: 'list-recent-output',
|
185
|
+
opt_name: 'list_recent_output',
|
186
|
+
proc1: 'val_as_bool'
|
187
|
+
},
|
188
|
+
{
|
189
|
+
description: 'List recent saved scripts',
|
190
|
+
long_name: 'list-recent-scripts',
|
191
|
+
opt_name: 'list_recent_scripts',
|
192
|
+
proc1: 'val_as_bool'
|
193
|
+
},
|
194
|
+
{
|
195
|
+
description: 'Select and execute a recently saved output',
|
196
|
+
long_name: 'select-recent-output',
|
197
|
+
opt_name: 'select_recent_output',
|
198
|
+
proc1: 'val_as_bool'
|
199
|
+
},
|
200
|
+
{
|
201
|
+
description: 'Select and execute a recently saved script',
|
202
|
+
long_name: 'select-recent-script',
|
203
|
+
opt_name: 'select_recent_script',
|
204
|
+
proc1: 'val_as_bool'
|
205
|
+
},
|
206
|
+
{
|
207
|
+
description: 'List tab completions',
|
208
|
+
long_name: 'tab-completions',
|
209
|
+
opt_name: 'tab_completions',
|
210
|
+
proc1: 'val_as_bool'
|
211
|
+
},
|
212
|
+
{
|
213
|
+
description: 'Run most recently saved script',
|
214
|
+
long_name: 'run-last-script',
|
215
|
+
opt_name: 'run_last_script',
|
216
|
+
proc1: 'val_as_bool'
|
217
|
+
},
|
218
|
+
{
|
219
|
+
description: 'Gem home folder',
|
220
|
+
long_name: 'pwd',
|
221
|
+
opt_name: 'pwd',
|
222
|
+
proc1: 'val_as_bool'
|
223
|
+
},
|
224
|
+
|
225
|
+
## secondary options
|
226
|
+
#
|
227
|
+
{
|
228
|
+
arg_name: "INT.#{DISPLAY_LEVEL_BASE}-#{DISPLAY_LEVEL_MAX}",
|
229
|
+
default: DISPLAY_LEVEL_DEFAULT,
|
230
|
+
description: "Output display level (#{DISPLAY_LEVEL_BASE} to #{DISPLAY_LEVEL_MAX} [data, +context, +info])",
|
231
|
+
env_var: 'MDE_DISPLAY_LEVEL',
|
232
|
+
long_name: 'display-level',
|
233
|
+
opt_name: 'display_level',
|
234
|
+
proc1: 'val_as_int'
|
235
|
+
},
|
236
|
+
{
|
237
|
+
arg_name: 'INT.1-',
|
238
|
+
default: 32,
|
239
|
+
description: 'Max. items to return in list',
|
240
|
+
env_var: 'MDE_LIST_COUNT',
|
241
|
+
long_name: 'list-count',
|
242
|
+
opt_name: 'list_count',
|
243
|
+
proc1: 'val_as_int'
|
244
|
+
},
|
245
|
+
{
|
246
|
+
arg_name: 'PREFIX',
|
247
|
+
default: MarkdownExec::BIN_NAME,
|
248
|
+
description: 'Name prefix for stdout files',
|
249
|
+
env_var: 'MDE_LOGGED_STDOUT_FILENAME_PREFIX',
|
250
|
+
# long_name: 'logged-stdout-filename-prefix',
|
251
|
+
opt_name: 'logged_stdout_filename_prefix',
|
252
|
+
proc1: 'val_as_str'
|
253
|
+
},
|
254
|
+
{
|
255
|
+
arg_name: 'BOOL',
|
256
|
+
default: false,
|
257
|
+
description: 'Display document name in block selection menu',
|
258
|
+
env_var: 'MDE_MENU_BLOCKS_WITH_DOCNAME',
|
259
|
+
# long_name: 'menu-blocks-with-docname',
|
260
|
+
opt_name: 'menu_blocks_with_docname',
|
261
|
+
proc1: 'val_as_bool'
|
262
|
+
},
|
263
|
+
{
|
264
|
+
arg_name: 'BOOL',
|
265
|
+
default: false,
|
266
|
+
description: 'Display headings (levels 1,2,3) in block selection menu',
|
267
|
+
env_var: 'MDE_MENU_BLOCKS_WITH_HEADINGS',
|
268
|
+
# long_name: 'menu-blocks-with-headings',
|
269
|
+
opt_name: 'menu_blocks_with_headings',
|
270
|
+
proc1: 'val_as_bool'
|
271
|
+
},
|
272
|
+
{
|
273
|
+
arg_name: 'BOOL',
|
274
|
+
default: false,
|
275
|
+
description: 'Display summary for execution',
|
276
|
+
env_var: 'MDE_OUTPUT_EXECUTION_SUMMARY',
|
277
|
+
long_name: 'output-execution-summary',
|
278
|
+
opt_name: 'output_execution_summary',
|
279
|
+
proc1: 'val_as_bool'
|
280
|
+
},
|
281
|
+
{
|
282
|
+
arg_name: 'BOOL',
|
283
|
+
default: false,
|
284
|
+
description: 'Display script prior to execution',
|
285
|
+
env_var: 'MDE_OUTPUT_SCRIPT',
|
286
|
+
long_name: 'output-script',
|
287
|
+
opt_name: 'output_script',
|
288
|
+
proc1: 'val_as_bool'
|
289
|
+
},
|
290
|
+
{
|
291
|
+
arg_name: 'BOOL',
|
292
|
+
default: true,
|
293
|
+
description: 'Display standard output from execution',
|
294
|
+
env_var: 'MDE_OUTPUT_STDOUT',
|
295
|
+
long_name: 'output-stdout',
|
296
|
+
opt_name: 'output_stdout',
|
297
|
+
proc1: 'val_as_bool'
|
298
|
+
},
|
299
|
+
{
|
300
|
+
arg_name: 'BOOL',
|
301
|
+
default: false,
|
302
|
+
description: 'Save executed script',
|
303
|
+
env_var: 'MDE_SAVE_EXECUTED_SCRIPT',
|
304
|
+
long_name: 'save-executed-script',
|
305
|
+
opt_name: 'save_executed_script',
|
306
|
+
proc1: 'val_as_bool'
|
307
|
+
},
|
308
|
+
{
|
309
|
+
arg_name: 'BOOL',
|
310
|
+
default: false,
|
311
|
+
description: 'Save standard output of the executed script',
|
312
|
+
env_var: 'MDE_SAVE_EXECUTION_OUTPUT',
|
313
|
+
long_name: 'save-execution-output',
|
314
|
+
opt_name: 'save_execution_output',
|
315
|
+
proc1: 'val_as_bool'
|
316
|
+
},
|
317
|
+
{
|
318
|
+
arg_name: 'INT',
|
319
|
+
default: 0o755,
|
320
|
+
description: 'chmod for saved scripts',
|
321
|
+
env_var: 'MDE_SAVED_SCRIPT_CHMOD',
|
322
|
+
# long_name: 'saved-script-chmod',
|
323
|
+
opt_name: 'saved_script_chmod',
|
324
|
+
proc1: 'val_as_int'
|
325
|
+
},
|
326
|
+
{
|
327
|
+
arg_name: 'PREFIX',
|
328
|
+
default: MarkdownExec::BIN_NAME,
|
329
|
+
description: 'Name prefix for saved scripts',
|
330
|
+
env_var: 'MDE_SAVED_SCRIPT_FILENAME_PREFIX',
|
331
|
+
# long_name: 'saved-script-filename-prefix',
|
332
|
+
opt_name: 'saved_script_filename_prefix',
|
333
|
+
proc1: 'val_as_str'
|
334
|
+
},
|
335
|
+
{
|
336
|
+
arg_name: 'RELATIVE_PATH',
|
337
|
+
default: 'logs',
|
338
|
+
description: 'Saved script folder',
|
339
|
+
env_var: 'MDE_SAVED_SCRIPT_FOLDER',
|
340
|
+
long_name: 'saved-script-folder',
|
341
|
+
opt_name: 'saved_script_folder',
|
342
|
+
proc1: 'val_as_str'
|
343
|
+
},
|
344
|
+
{
|
345
|
+
arg_name: 'GLOB',
|
346
|
+
default: 'mde_*.sh',
|
347
|
+
description: 'Glob matching saved scripts',
|
348
|
+
env_var: 'MDE_SAVED_SCRIPT_GLOB',
|
349
|
+
# long_name: 'saved-script-glob',
|
350
|
+
opt_name: 'saved_script_glob',
|
351
|
+
proc1: 'val_as_str'
|
352
|
+
},
|
353
|
+
{
|
354
|
+
arg_name: 'RELATIVE_PATH',
|
355
|
+
default: 'logs',
|
356
|
+
description: 'Saved stdout folder',
|
357
|
+
env_var: 'MDE_SAVED_STDOUT_FOLDER',
|
358
|
+
long_name: 'saved-stdout-folder',
|
359
|
+
opt_name: 'saved_stdout_folder',
|
360
|
+
proc1: 'val_as_str'
|
361
|
+
},
|
362
|
+
{
|
363
|
+
arg_name: 'GLOB',
|
364
|
+
default: 'mde_*.out.txt',
|
365
|
+
description: 'Glob matching saved outputs',
|
366
|
+
env_var: 'MDE_SAVED_STDOUT_GLOB',
|
367
|
+
# long_name: 'saved-stdout-glob',
|
368
|
+
opt_name: 'saved_stdout_glob',
|
369
|
+
proc1: 'val_as_str'
|
370
|
+
},
|
371
|
+
|
372
|
+
{
|
373
|
+
default: '^[\(\[].*[\)\]]$',
|
374
|
+
description: 'Pattern for blocks to hide from user-selection',
|
375
|
+
env_var: 'MDE_BLOCK_NAME_EXCLUDED_MATCH',
|
376
|
+
opt_name: 'block_name_excluded_match',
|
377
|
+
proc1: 'val_as_str'
|
378
|
+
},
|
379
|
+
{
|
380
|
+
default: ':(?<title>\S+)( |$)',
|
381
|
+
env_var: 'MDE_BLOCK_NAME_MATCH',
|
382
|
+
opt_name: 'block_name_match',
|
383
|
+
proc1: 'val_as_str'
|
384
|
+
},
|
385
|
+
{
|
386
|
+
default: '%\([^\)]+\)',
|
387
|
+
env_var: 'MDE_BLOCK_CALLS_SCAN',
|
388
|
+
opt_name: 'block_calls_scan',
|
389
|
+
proc1: 'val_as_str'
|
390
|
+
},
|
391
|
+
{
|
392
|
+
default: '\+\S+',
|
393
|
+
env_var: 'MDE_BLOCK_REQUIRED_SCAN',
|
394
|
+
opt_name: 'block_required_scan',
|
395
|
+
proc1: 'val_as_str'
|
396
|
+
},
|
397
|
+
{
|
398
|
+
default: '<(?<full>(?<type>\$)?(?<name>[A-Za-z]\S*))',
|
399
|
+
env_var: 'MDE_BLOCK_STDIN_SCAN',
|
400
|
+
opt_name: 'block_stdin_scan',
|
401
|
+
proc1: 'val_as_str'
|
402
|
+
},
|
403
|
+
{
|
404
|
+
default: '>(?<full>(?<type>\$)?(?<name>[A-Za-z]\S*))',
|
405
|
+
env_var: 'MDE_BLOCK_STDOUT_SCAN',
|
406
|
+
opt_name: 'block_stdout_scan',
|
407
|
+
proc1: 'val_as_str'
|
408
|
+
},
|
409
|
+
{
|
410
|
+
default: '> ',
|
411
|
+
env_var: 'MDE_DISPLAY_LEVEL_XBASE_PREFIX',
|
412
|
+
opt_name: 'display_level_xbase_prefix',
|
413
|
+
proc1: 'val_as_str'
|
414
|
+
},
|
415
|
+
{
|
416
|
+
default: '^`{3,}',
|
417
|
+
env_var: 'MDE_FENCED_START_AND_END_MATCH',
|
418
|
+
opt_name: 'fenced_start_and_end_match',
|
419
|
+
proc1: 'val_as_str'
|
420
|
+
},
|
421
|
+
{
|
422
|
+
default: '^`{3,}(?<shell>[^`\s]*) *(?<name>.*)$',
|
423
|
+
env_var: 'MDE_FENCED_START_EX_MATCH',
|
424
|
+
opt_name: 'fenced_start_ex_match',
|
425
|
+
proc1: 'val_as_str'
|
426
|
+
},
|
427
|
+
{
|
428
|
+
default: '^# *(?<name>[^#]*?) *$',
|
429
|
+
env_var: 'MDE_HEADING1_MATCH',
|
430
|
+
opt_name: 'heading1_match',
|
431
|
+
proc1: 'val_as_str'
|
432
|
+
},
|
433
|
+
{
|
434
|
+
default: '^## *(?<name>[^#]*?) *$',
|
435
|
+
env_var: 'MDE_HEADING2_MATCH',
|
436
|
+
opt_name: 'heading2_match',
|
437
|
+
proc1: 'val_as_str'
|
438
|
+
},
|
439
|
+
{
|
440
|
+
default: '^### *(?<name>.+?) *$',
|
441
|
+
env_var: 'MDE_HEADING3_MATCH',
|
442
|
+
opt_name: 'heading3_match',
|
443
|
+
proc1: 'val_as_str'
|
444
|
+
},
|
445
|
+
{
|
446
|
+
default: '*.[Mm][Dd]',
|
447
|
+
env_var: 'MDE_MD_FILENAME_GLOB',
|
448
|
+
opt_name: 'md_filename_glob',
|
449
|
+
proc1: 'val_as_str'
|
450
|
+
},
|
451
|
+
{
|
452
|
+
default: '.+\\.md',
|
453
|
+
env_var: 'MDE_MD_FILENAME_MATCH',
|
454
|
+
opt_name: 'md_filename_match',
|
455
|
+
proc1: 'val_as_str'
|
456
|
+
},
|
457
|
+
{
|
458
|
+
default: '^::: +(?<name>.+?)$',
|
459
|
+
description: 'Pattern for topics/dividers in block selection menu',
|
460
|
+
env_var: 'MDE_MENU_DIVIDER_MATCH',
|
461
|
+
opt_name: 'menu_divider_match',
|
462
|
+
proc1: 'val_as_str'
|
463
|
+
},
|
464
|
+
{
|
465
|
+
description: 'Options for viewing saved output file',
|
466
|
+
env_var: 'MDE_OUTPUT_VIEWER_OPTIONS',
|
467
|
+
opt_name: 'output_viewer_options',
|
468
|
+
proc1: 'val_as_str'
|
469
|
+
},
|
470
|
+
{
|
471
|
+
default: 24,
|
472
|
+
description: 'Maximum # of rows in select list',
|
473
|
+
env_var: 'MDE_SELECT_PAGE_HEIGHT',
|
474
|
+
opt_name: 'select_page_height',
|
475
|
+
proc1: 'val_as_int'
|
476
|
+
},
|
477
|
+
{
|
478
|
+
default: '#!/usr/bin/env',
|
479
|
+
description: 'Shebang for saved scripts',
|
480
|
+
env_var: 'MDE_SHEBANG',
|
481
|
+
opt_name: 'shebang',
|
482
|
+
proc1: 'val_as_str'
|
483
|
+
},
|
484
|
+
{
|
485
|
+
default: 'bash',
|
486
|
+
description: 'Shell for launched scripts',
|
487
|
+
env_var: 'MDE_SHELL',
|
488
|
+
opt_name: 'shell',
|
489
|
+
proc1: 'val_as_str'
|
490
|
+
},
|
491
|
+
{
|
492
|
+
default: '- - %s - -',
|
493
|
+
env_var: 'MDE_MENU_DIVIDER_FORMAT',
|
494
|
+
opt_name: 'menu_divider_format',
|
495
|
+
proc1: 'val_as_str'
|
496
|
+
}
|
497
|
+
]
|
498
|
+
|
499
|
+
File.write(MENU_YML,
|
500
|
+
"# #{MarkdownExec::APP_NAME} - #{MarkdownExec::APP_DESC} (#{MarkdownExec::VERSION})\n" +
|
501
|
+
menu_options.to_yaml)
|
502
|
+
puts `stat #{MENU_YML}`
|
503
|
+
end
|
504
|
+
|
505
|
+
# write tab_completion.sh with erb
|
506
|
+
#
|
62
507
|
def update_tab_completion(target)
|
63
508
|
words = `#{File.join BF, MarkdownExec::BIN_NAME} --tab-completions`.split("\n")
|
64
|
-
mde_tab_completions =
|
509
|
+
mde_tab_completions = "(#{words_list(words)})"
|
65
510
|
mde_help = `#{File.join BF, MarkdownExec::BIN_NAME} --help`.split("\n")
|
66
|
-
menu_export_yaml = `#{File.join BF, MarkdownExec::BIN_NAME} --menu-export`
|
67
511
|
|
68
|
-
svhs = YAML.load
|
512
|
+
svhs = YAML.load File.open(MENU_YML)
|
69
513
|
svhs.each do |svh|
|
70
514
|
svh[:compreply] = value_for_cli(svh[:default]) if svh[:compreply].nil?
|
71
515
|
end.tap_inspect name: :svhs, format: :yaml
|
72
516
|
|
73
|
-
File.write target, ERB.new(File.read(File.join(BF, 'tab_completion.sh.erb'))).result(binding)
|
517
|
+
File.write target, ERB.new(File.read(filespec = File.join(BF, 'tab_completion.sh.erb'))).result(binding)
|
518
|
+
puts `stat #{filespec}`
|
74
519
|
end
|
75
520
|
|
76
521
|
desc 'update tab_completion.sh'
|
@@ -78,9 +523,18 @@ task :update_tab_completion do
|
|
78
523
|
update_tab_completion File.join(BF, 'tab_completion.sh')
|
79
524
|
end
|
80
525
|
|
81
|
-
desc 'update tab_completion.sh'
|
526
|
+
desc 'update installed tab_completion.sh'
|
82
527
|
task :update_installed_tab_completion do
|
83
528
|
update_tab_completion(fs = File.join(`mde --pwd`.chomp, BF, 'tab_completion.sh'))
|
84
529
|
|
85
530
|
puts `cat #{fs}` ###
|
86
531
|
end
|
532
|
+
|
533
|
+
# format for use in array in bash script
|
534
|
+
# `opts=<%= mde_tab_completions %>`
|
535
|
+
#
|
536
|
+
def words_list(words)
|
537
|
+
words.map do |word|
|
538
|
+
%("#{word}")
|
539
|
+
end.join ' '
|
540
|
+
end
|
data/bin/tab_completion.sh
CHANGED
@@ -13,7 +13,7 @@ __filedirs_all()
|
|
13
13
|
}
|
14
14
|
|
15
15
|
_mde_echo_version() {
|
16
|
-
echo "1.
|
16
|
+
echo "1.3.0"
|
17
17
|
}
|
18
18
|
|
19
19
|
_mde() {
|
@@ -34,13 +34,15 @@ _mde() {
|
|
34
34
|
|
35
35
|
--debug) COMPREPLY="0"; return 0 ;;
|
36
36
|
|
37
|
-
--display-level) COMPREPLY="1"; return 0 ;;
|
38
|
-
|
39
37
|
--filename) COMPREPLY="."; return 0 ;;
|
40
38
|
|
41
|
-
--
|
39
|
+
--path) COMPREPLY="."; return 0 ;;
|
42
40
|
|
43
|
-
--
|
41
|
+
--user-must-approve) COMPREPLY="1"; return 0 ;;
|
42
|
+
|
43
|
+
--display-level) COMPREPLY="1"; return 0 ;;
|
44
|
+
|
45
|
+
--list-count) COMPREPLY="32"; return 0 ;;
|
44
46
|
|
45
47
|
--output-execution-summary) COMPREPLY="0"; return 0 ;;
|
46
48
|
|
@@ -48,26 +50,14 @@ _mde() {
|
|
48
50
|
|
49
51
|
--output-stdout) COMPREPLY="1"; return 0 ;;
|
50
52
|
|
51
|
-
--path) COMPREPLY="."; return 0 ;;
|
52
|
-
|
53
53
|
--save-executed-script) COMPREPLY="0"; return 0 ;;
|
54
54
|
|
55
55
|
--save-execution-output) COMPREPLY="0"; return 0 ;;
|
56
56
|
|
57
|
-
--saved-script-chmod) COMPREPLY="493"; return 0 ;;
|
58
|
-
|
59
|
-
--saved-script-filename-prefix) COMPREPLY="mde"; return 0 ;;
|
60
|
-
|
61
57
|
--saved-script-folder) COMPREPLY="logs"; return 0 ;;
|
62
58
|
|
63
|
-
--saved-script-glob) COMPREPLY="mde_\*.sh"; return 0 ;;
|
64
|
-
|
65
59
|
--saved-stdout-folder) COMPREPLY="logs"; return 0 ;;
|
66
60
|
|
67
|
-
--saved-stdout-glob) COMPREPLY="mde_\*.out.txt"; return 0 ;;
|
68
|
-
|
69
|
-
--user-must-approve) COMPREPLY="1"; return 0 ;;
|
70
|
-
|
71
61
|
esac
|
72
62
|
fi
|
73
63
|
fi
|
@@ -76,7 +66,7 @@ _mde() {
|
|
76
66
|
# present matching option names
|
77
67
|
#
|
78
68
|
if [[ ${cur} == -* ]] ; then
|
79
|
-
opts=("--list-blocks" "--list-default-env" "--list-default-yaml" "--list-docs" "--list-recent-output" "--list-recent-scripts" "--
|
69
|
+
opts=("--block-name" "--config" "--debug" "--filename" "--help" "--path" "--user-must-approve" "--version" "--exit" "--list-blocks" "--list-default-env" "--list-default-yaml" "--list-docs" "--list-recent-output" "--list-recent-scripts" "--select-recent-output" "--select-recent-script" "--tab-completions" "--run-last-script" "--pwd" "--display-level" "--list-count" "--output-execution-summary" "--output-script" "--output-stdout" "--save-executed-script" "--save-execution-output" "--saved-script-folder" "--saved-stdout-folder")
|
80
70
|
COMPREPLY=( $(compgen -W "$(printf "'%s' " "${opts[@]}")" -- "${cur}") )
|
81
71
|
|
82
72
|
return 0
|
@@ -89,19 +79,21 @@ _mde() {
|
|
89
79
|
if [[ -z ${cur} ]] ; then
|
90
80
|
case $prev in
|
91
81
|
|
82
|
+
--block-name) COMPREPLY=".NAME."; return 0 ;;
|
83
|
+
|
92
84
|
--config) COMPREPLY=".PATH."; return 0 ;;
|
93
85
|
|
94
86
|
--debug) COMPREPLY=".BOOL."; return 0 ;;
|
95
87
|
|
96
|
-
--
|
88
|
+
--filename) COMPREPLY=".RELATIVE_PATH."; return 0 ;;
|
97
89
|
|
98
|
-
--
|
90
|
+
--path) COMPREPLY=".RELATIVE_PATH."; return 0 ;;
|
99
91
|
|
100
|
-
--
|
92
|
+
--user-must-approve) COMPREPLY=".BOOL."; return 0 ;;
|
101
93
|
|
102
|
-
--
|
94
|
+
--display-level) COMPREPLY=".INT.0-2."; return 0 ;;
|
103
95
|
|
104
|
-
--
|
96
|
+
--list-count) COMPREPLY=".INT.1-."; return 0 ;;
|
105
97
|
|
106
98
|
--output-execution-summary) COMPREPLY=".BOOL."; return 0 ;;
|
107
99
|
|
@@ -109,26 +101,14 @@ _mde() {
|
|
109
101
|
|
110
102
|
--output-stdout) COMPREPLY=".BOOL."; return 0 ;;
|
111
103
|
|
112
|
-
--path) COMPREPLY=".RELATIVE_PATH."; return 0 ;;
|
113
|
-
|
114
104
|
--save-executed-script) COMPREPLY=".BOOL."; return 0 ;;
|
115
105
|
|
116
106
|
--save-execution-output) COMPREPLY=".BOOL."; return 0 ;;
|
117
107
|
|
118
|
-
--saved-script-chmod) COMPREPLY=".INT."; return 0 ;;
|
119
|
-
|
120
|
-
--saved-script-filename-prefix) COMPREPLY=".PREFIX."; return 0 ;;
|
121
|
-
|
122
108
|
--saved-script-folder) COMPREPLY=".RELATIVE_PATH."; return 0 ;;
|
123
109
|
|
124
|
-
--saved-script-glob) COMPREPLY=".GLOB."; return 0 ;;
|
125
|
-
|
126
110
|
--saved-stdout-folder) COMPREPLY=".RELATIVE_PATH."; return 0 ;;
|
127
111
|
|
128
|
-
--saved-stdout-glob) COMPREPLY=".GLOB."; return 0 ;;
|
129
|
-
|
130
|
-
--user-must-approve) COMPREPLY=".BOOL."; return 0 ;;
|
131
|
-
|
132
112
|
esac
|
133
113
|
fi
|
134
114
|
|
@@ -140,4 +120,4 @@ _mde() {
|
|
140
120
|
|
141
121
|
complete -o filenames -o nospace -F _mde mde
|
142
122
|
# _mde_echo_version
|
143
|
-
# echo "Updated: 2022-
|
123
|
+
# echo "Updated: 2022-07-16 23:32:32 UTC"
|