markdown_exec 1.2.0 → 1.3.0
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/.reek +3 -1
- data/.rubocop.yml +18 -0
- data/CHANGELOG.md +61 -0
- data/Gemfile.lock +1 -1
- data/README.md +25 -4
- data/Rakefile +450 -16
- data/bin/tab_completion.sh +13 -41
- data/lib/globfiles.rb +40 -0
- data/lib/markdown_exec/version.rb +3 -1
- data/lib/markdown_exec.rb +255 -529
- data/lib/menu.yml +293 -0
- data/lib/shared.rb +21 -0
- data/lib/tap.rb +13 -7
- metadata +4 -2
data/Rakefile
CHANGED
@@ -13,10 +13,12 @@ end
|
|
13
13
|
|
14
14
|
require 'rubocop/rake_task'
|
15
15
|
|
16
|
+
require_relative 'lib/markdown_exec/version'
|
16
17
|
require_relative 'lib/shared'
|
17
18
|
require_relative 'lib/tap'
|
18
19
|
|
19
|
-
include Tap
|
20
|
+
include Tap
|
21
|
+
tap_config envvar: MarkdownExec::TAP_DEBUG
|
20
22
|
|
21
23
|
RuboCop::RakeTask.new do |task|
|
22
24
|
task.requires << 'rubocop-minitest'
|
@@ -27,15 +29,14 @@ task :rubocopminitest do
|
|
27
29
|
`rubocop --require rubocop-minitest`
|
28
30
|
end
|
29
31
|
|
30
|
-
require_relative 'lib/markdown_exec/version'
|
31
|
-
|
32
32
|
task default: %i[test reek rubocop rubocopminitest]
|
33
33
|
|
34
34
|
# task :default => :build
|
35
35
|
|
36
36
|
desc 'gem build'
|
37
37
|
task :build do
|
38
|
-
Rake::Task['
|
38
|
+
Rake::Task['update_menu_yml'].execute
|
39
|
+
Rake::Task['update_tab_completion'].execute # after updated menu is readable
|
39
40
|
system "gem build #{MarkdownExec::GEM_NAME}.gemspec"
|
40
41
|
end
|
41
42
|
|
@@ -66,15 +67,439 @@ end
|
|
66
67
|
|
67
68
|
private
|
68
69
|
|
69
|
-
|
70
|
-
|
71
|
-
# format for use in array in bash script
|
72
|
-
# `opts=<%= mde_tab_completions %>`
|
70
|
+
# write menu.yml
|
73
71
|
#
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
72
|
+
desc 'update menu.yml'
|
73
|
+
task :update_menu_yml do
|
74
|
+
menu_options = [
|
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}`
|
78
503
|
end
|
79
504
|
|
80
505
|
# write tab_completion.sh with erb
|
@@ -83,14 +508,14 @@ def update_tab_completion(target)
|
|
83
508
|
words = `#{File.join BF, MarkdownExec::BIN_NAME} --tab-completions`.split("\n")
|
84
509
|
mde_tab_completions = "(#{words_list(words)})"
|
85
510
|
mde_help = `#{File.join BF, MarkdownExec::BIN_NAME} --help`.split("\n")
|
86
|
-
menu_export_yaml = `#{File.join BF, MarkdownExec::BIN_NAME} --menu-export`
|
87
511
|
|
88
|
-
svhs = YAML.load
|
512
|
+
svhs = YAML.load File.open(MENU_YML)
|
89
513
|
svhs.each do |svh|
|
90
514
|
svh[:compreply] = value_for_cli(svh[:default]) if svh[:compreply].nil?
|
91
515
|
end.tap_inspect name: :svhs, format: :yaml
|
92
516
|
|
93
|
-
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}`
|
94
519
|
end
|
95
520
|
|
96
521
|
desc 'update tab_completion.sh'
|
@@ -98,9 +523,18 @@ task :update_tab_completion do
|
|
98
523
|
update_tab_completion File.join(BF, 'tab_completion.sh')
|
99
524
|
end
|
100
525
|
|
101
|
-
desc 'update tab_completion.sh'
|
526
|
+
desc 'update installed tab_completion.sh'
|
102
527
|
task :update_installed_tab_completion do
|
103
528
|
update_tab_completion(fs = File.join(`mde --pwd`.chomp, BF, 'tab_completion.sh'))
|
104
529
|
|
105
530
|
puts `cat #{fs}` ###
|
106
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,17 +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 ;;
|
44
42
|
|
45
|
-
--
|
43
|
+
--display-level) COMPREPLY="1"; return 0 ;;
|
46
44
|
|
47
|
-
--
|
45
|
+
--list-count) COMPREPLY="32"; return 0 ;;
|
48
46
|
|
49
47
|
--output-execution-summary) COMPREPLY="0"; return 0 ;;
|
50
48
|
|
@@ -52,26 +50,14 @@ _mde() {
|
|
52
50
|
|
53
51
|
--output-stdout) COMPREPLY="1"; return 0 ;;
|
54
52
|
|
55
|
-
--path) COMPREPLY="."; return 0 ;;
|
56
|
-
|
57
53
|
--save-executed-script) COMPREPLY="0"; return 0 ;;
|
58
54
|
|
59
55
|
--save-execution-output) COMPREPLY="0"; return 0 ;;
|
60
56
|
|
61
|
-
--saved-script-chmod) COMPREPLY="493"; return 0 ;;
|
62
|
-
|
63
|
-
--saved-script-filename-prefix) COMPREPLY="mde"; return 0 ;;
|
64
|
-
|
65
57
|
--saved-script-folder) COMPREPLY="logs"; return 0 ;;
|
66
58
|
|
67
|
-
--saved-script-glob) COMPREPLY="mde_\*.sh"; return 0 ;;
|
68
|
-
|
69
59
|
--saved-stdout-folder) COMPREPLY="logs"; return 0 ;;
|
70
60
|
|
71
|
-
--saved-stdout-glob) COMPREPLY="mde_\*.out.txt"; return 0 ;;
|
72
|
-
|
73
|
-
--user-must-approve) COMPREPLY="1"; return 0 ;;
|
74
|
-
|
75
61
|
esac
|
76
62
|
fi
|
77
63
|
fi
|
@@ -80,7 +66,7 @@ _mde() {
|
|
80
66
|
# present matching option names
|
81
67
|
#
|
82
68
|
if [[ ${cur} == -* ]] ; then
|
83
|
-
opts=("--
|
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")
|
84
70
|
COMPREPLY=( $(compgen -W "$(printf "'%s' " "${opts[@]}")" -- "${cur}") )
|
85
71
|
|
86
72
|
return 0
|
@@ -93,23 +79,21 @@ _mde() {
|
|
93
79
|
if [[ -z ${cur} ]] ; then
|
94
80
|
case $prev in
|
95
81
|
|
82
|
+
--block-name) COMPREPLY=".NAME."; return 0 ;;
|
83
|
+
|
96
84
|
--config) COMPREPLY=".PATH."; return 0 ;;
|
97
85
|
|
98
86
|
--debug) COMPREPLY=".BOOL."; return 0 ;;
|
99
87
|
|
100
|
-
--display-level) COMPREPLY=".INT.0-2."; return 0 ;;
|
101
|
-
|
102
|
-
--block-name) COMPREPLY=".NAME."; return 0 ;;
|
103
|
-
|
104
88
|
--filename) COMPREPLY=".RELATIVE_PATH."; return 0 ;;
|
105
89
|
|
106
|
-
--
|
90
|
+
--path) COMPREPLY=".RELATIVE_PATH."; return 0 ;;
|
107
91
|
|
108
|
-
--
|
92
|
+
--user-must-approve) COMPREPLY=".BOOL."; return 0 ;;
|
109
93
|
|
110
|
-
--
|
94
|
+
--display-level) COMPREPLY=".INT.0-2."; return 0 ;;
|
111
95
|
|
112
|
-
--
|
96
|
+
--list-count) COMPREPLY=".INT.1-."; return 0 ;;
|
113
97
|
|
114
98
|
--output-execution-summary) COMPREPLY=".BOOL."; return 0 ;;
|
115
99
|
|
@@ -117,26 +101,14 @@ _mde() {
|
|
117
101
|
|
118
102
|
--output-stdout) COMPREPLY=".BOOL."; return 0 ;;
|
119
103
|
|
120
|
-
--path) COMPREPLY=".RELATIVE_PATH."; return 0 ;;
|
121
|
-
|
122
104
|
--save-executed-script) COMPREPLY=".BOOL."; return 0 ;;
|
123
105
|
|
124
106
|
--save-execution-output) COMPREPLY=".BOOL."; return 0 ;;
|
125
107
|
|
126
|
-
--saved-script-chmod) COMPREPLY=".INT."; return 0 ;;
|
127
|
-
|
128
|
-
--saved-script-filename-prefix) COMPREPLY=".PREFIX."; return 0 ;;
|
129
|
-
|
130
108
|
--saved-script-folder) COMPREPLY=".RELATIVE_PATH."; return 0 ;;
|
131
109
|
|
132
|
-
--saved-script-glob) COMPREPLY=".GLOB."; return 0 ;;
|
133
|
-
|
134
110
|
--saved-stdout-folder) COMPREPLY=".RELATIVE_PATH."; return 0 ;;
|
135
111
|
|
136
|
-
--saved-stdout-glob) COMPREPLY=".GLOB."; return 0 ;;
|
137
|
-
|
138
|
-
--user-must-approve) COMPREPLY=".BOOL."; return 0 ;;
|
139
|
-
|
140
112
|
esac
|
141
113
|
fi
|
142
114
|
|
@@ -148,4 +120,4 @@ _mde() {
|
|
148
120
|
|
149
121
|
complete -o filenames -o nospace -F _mde mde
|
150
122
|
# _mde_echo_version
|
151
|
-
# echo "Updated: 2022-
|
123
|
+
# echo "Updated: 2022-07-16 23:32:32 UTC"
|
data/lib/globfiles.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# encoding=utf-8
|
4
|
+
|
5
|
+
# require 'json'
|
6
|
+
# require 'yaml'
|
7
|
+
|
8
|
+
# require_relative 'env'
|
9
|
+
# include Env
|
10
|
+
|
11
|
+
## directory listing of saved files matching glob
|
12
|
+
#
|
13
|
+
class Globfiles
|
14
|
+
def initialize(folder, glob)
|
15
|
+
@folder = folder
|
16
|
+
@glob = glob
|
17
|
+
end
|
18
|
+
|
19
|
+
def list_all
|
20
|
+
Dir.glob(File.join(@folder, @glob)).tap_inspect
|
21
|
+
end
|
22
|
+
|
23
|
+
## single most recent item
|
24
|
+
#
|
25
|
+
def most_recent(arr = nil)
|
26
|
+
arr = list_all if arr.nil?
|
27
|
+
return if arr.count < 1
|
28
|
+
|
29
|
+
arr.max.tap_inspect
|
30
|
+
end
|
31
|
+
|
32
|
+
## multiple recent items
|
33
|
+
#
|
34
|
+
def most_recent_list(list_count, arr = nil)
|
35
|
+
arr = list_all if arr.nil?
|
36
|
+
return if (ac = arr.count) < 1
|
37
|
+
|
38
|
+
arr.sort[-[ac, list_count].min..].reverse.tap_inspect
|
39
|
+
end
|
40
|
+
end # class Globfiles
|