markdown_exec 1.3.0 → 1.3.1
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 -0
- data/.rubocop.yml +3 -0
- data/CHANGELOG.md +32 -9
- data/Gemfile +5 -0
- data/Gemfile.lock +15 -13
- data/README.md +56 -0
- data/Rakefile +182 -63
- data/bin/tab_completion.sh +21 -3
- data/bin/tab_completion.sh.erb +23 -0
- data/lib/cli.rb +19 -0
- data/lib/environment_opt_parse.rb +200 -0
- data/lib/markdown_exec/version.rb +1 -1
- data/lib/markdown_exec.rb +222 -139
- data/lib/menu.yml +135 -64
- data/lib/object_present.rb +40 -0
- data/lib/shared.rb +3 -14
- data/lib/tap.rb +76 -21
- metadata +5 -2
data/lib/menu.yml
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# MDE - Markdown Executor (1.3.
|
1
|
+
# MDE - Markdown Executor (1.3.1)
|
2
2
|
---
|
3
3
|
- :arg_name: NAME
|
4
4
|
:compreply: false
|
@@ -7,19 +7,19 @@
|
|
7
7
|
:long_name: block-name
|
8
8
|
:opt_name: block_name
|
9
9
|
:short_name: b
|
10
|
-
:
|
10
|
+
:procname: val_as_str
|
11
11
|
- :arg_name: PATH
|
12
12
|
:default: "."
|
13
13
|
:description: Read configuration file
|
14
14
|
:long_name: config
|
15
|
-
:
|
15
|
+
:procname: path
|
16
16
|
- :arg_name: BOOL
|
17
17
|
:default: false
|
18
18
|
:description: Debug output
|
19
19
|
:env_var: MDE_DEBUG
|
20
20
|
:long_name: debug
|
21
21
|
:short_name: d
|
22
|
-
:
|
22
|
+
:procname: debug
|
23
23
|
- :arg_name: RELATIVE_PATH
|
24
24
|
:compreply: "."
|
25
25
|
:description: Name of document
|
@@ -27,11 +27,11 @@
|
|
27
27
|
:long_name: filename
|
28
28
|
:opt_name: filename
|
29
29
|
:short_name: f
|
30
|
-
:
|
30
|
+
:procname: val_as_str
|
31
31
|
- :description: App help
|
32
32
|
:long_name: help
|
33
33
|
:short_name: h
|
34
|
-
:
|
34
|
+
:procname: help
|
35
35
|
- :arg_name: RELATIVE_PATH
|
36
36
|
:default: "."
|
37
37
|
:description: Path to documents
|
@@ -39,7 +39,7 @@
|
|
39
39
|
:long_name: path
|
40
40
|
:opt_name: path
|
41
41
|
:short_name: p
|
42
|
-
:
|
42
|
+
:procname: val_as_str
|
43
43
|
- :arg_name: BOOL
|
44
44
|
:default: true
|
45
45
|
:description: Pause for user to approve script
|
@@ -47,22 +47,22 @@
|
|
47
47
|
:long_name: user-must-approve
|
48
48
|
:opt_name: user_must_approve
|
49
49
|
:short_name: q
|
50
|
-
:
|
50
|
+
:procname: val_as_bool
|
51
51
|
- :description: Print the gem's version
|
52
52
|
:long_name: version
|
53
53
|
:short_name: v
|
54
|
-
:
|
54
|
+
:procname: version
|
55
55
|
- :description: Exit app
|
56
56
|
:long_name: exit
|
57
57
|
:short_name: x
|
58
|
-
:
|
58
|
+
:procname: exit
|
59
59
|
- :description: Show current configuration values
|
60
60
|
:short_name: '0'
|
61
|
-
:
|
61
|
+
:procname: show_config
|
62
62
|
- :description: List blocks
|
63
63
|
:long_name: list-blocks
|
64
64
|
:opt_name: list_blocks
|
65
|
-
:
|
65
|
+
:procname: val_as_bool
|
66
66
|
- :description: List default configuration as environment variables
|
67
67
|
:long_name: list-default-env
|
68
68
|
:opt_name: list_default_env
|
@@ -72,222 +72,293 @@
|
|
72
72
|
- :description: List docs in current folder
|
73
73
|
:long_name: list-docs
|
74
74
|
:opt_name: list_docs
|
75
|
-
:
|
75
|
+
:procname: val_as_bool
|
76
76
|
- :description: List recent saved output
|
77
77
|
:long_name: list-recent-output
|
78
78
|
:opt_name: list_recent_output
|
79
|
-
:
|
79
|
+
:procname: val_as_bool
|
80
80
|
- :description: List recent saved scripts
|
81
81
|
:long_name: list-recent-scripts
|
82
82
|
:opt_name: list_recent_scripts
|
83
|
-
:
|
83
|
+
:procname: val_as_bool
|
84
84
|
- :description: Select and execute a recently saved output
|
85
85
|
:long_name: select-recent-output
|
86
86
|
:opt_name: select_recent_output
|
87
|
-
:
|
87
|
+
:procname: val_as_bool
|
88
88
|
- :description: Select and execute a recently saved script
|
89
89
|
:long_name: select-recent-script
|
90
90
|
:opt_name: select_recent_script
|
91
|
-
:
|
91
|
+
:procname: val_as_bool
|
92
92
|
- :description: List tab completions
|
93
93
|
:long_name: tab-completions
|
94
94
|
:opt_name: tab_completions
|
95
|
-
:
|
95
|
+
:procname: val_as_bool
|
96
96
|
- :description: Run most recently saved script
|
97
97
|
:long_name: run-last-script
|
98
98
|
:opt_name: run_last_script
|
99
|
-
:
|
99
|
+
:procname: val_as_bool
|
100
100
|
- :description: Gem home folder
|
101
101
|
:long_name: pwd
|
102
102
|
:opt_name: pwd
|
103
|
-
:
|
104
|
-
- :arg_name: INT.0-
|
103
|
+
:procname: val_as_bool
|
104
|
+
- :arg_name: INT.0-3
|
105
105
|
:default: 1
|
106
|
-
:description: Output display level (0 to
|
106
|
+
:description: Output display level (0 to 3 [data, +context, +info])
|
107
107
|
:env_var: MDE_DISPLAY_LEVEL
|
108
108
|
:long_name: display-level
|
109
109
|
:opt_name: display_level
|
110
|
-
:
|
110
|
+
:procname: val_as_int
|
111
111
|
- :arg_name: INT.1-
|
112
112
|
:default: 32
|
113
113
|
:description: Max. items to return in list
|
114
114
|
:env_var: MDE_LIST_COUNT
|
115
115
|
:long_name: list-count
|
116
116
|
:opt_name: list_count
|
117
|
-
:
|
117
|
+
:procname: val_as_int
|
118
118
|
- :arg_name: PREFIX
|
119
119
|
:default: mde
|
120
120
|
:description: Name prefix for stdout files
|
121
121
|
:env_var: MDE_LOGGED_STDOUT_FILENAME_PREFIX
|
122
122
|
:opt_name: logged_stdout_filename_prefix
|
123
|
-
:
|
123
|
+
:procname: val_as_str
|
124
124
|
- :arg_name: BOOL
|
125
125
|
:default: false
|
126
126
|
:description: Display document name in block selection menu
|
127
127
|
:env_var: MDE_MENU_BLOCKS_WITH_DOCNAME
|
128
128
|
:opt_name: menu_blocks_with_docname
|
129
|
-
:
|
129
|
+
:procname: val_as_bool
|
130
130
|
- :arg_name: BOOL
|
131
131
|
:default: false
|
132
132
|
:description: Display headings (levels 1,2,3) in block selection menu
|
133
133
|
:env_var: MDE_MENU_BLOCKS_WITH_HEADINGS
|
134
134
|
:opt_name: menu_blocks_with_headings
|
135
|
-
:
|
135
|
+
:procname: val_as_bool
|
136
136
|
- :arg_name: BOOL
|
137
137
|
:default: false
|
138
138
|
:description: Display summary for execution
|
139
139
|
:env_var: MDE_OUTPUT_EXECUTION_SUMMARY
|
140
140
|
:long_name: output-execution-summary
|
141
141
|
:opt_name: output_execution_summary
|
142
|
-
:
|
142
|
+
:procname: val_as_bool
|
143
143
|
- :arg_name: BOOL
|
144
144
|
:default: false
|
145
145
|
:description: Display script prior to execution
|
146
146
|
:env_var: MDE_OUTPUT_SCRIPT
|
147
147
|
:long_name: output-script
|
148
148
|
:opt_name: output_script
|
149
|
-
:
|
149
|
+
:procname: val_as_bool
|
150
150
|
- :arg_name: BOOL
|
151
151
|
:default: true
|
152
152
|
:description: Display standard output from execution
|
153
153
|
:env_var: MDE_OUTPUT_STDOUT
|
154
154
|
:long_name: output-stdout
|
155
155
|
:opt_name: output_stdout
|
156
|
-
:
|
156
|
+
:procname: val_as_bool
|
157
157
|
- :arg_name: BOOL
|
158
158
|
:default: false
|
159
159
|
:description: Save executed script
|
160
160
|
:env_var: MDE_SAVE_EXECUTED_SCRIPT
|
161
161
|
:long_name: save-executed-script
|
162
162
|
:opt_name: save_executed_script
|
163
|
-
:
|
163
|
+
:procname: val_as_bool
|
164
164
|
- :arg_name: BOOL
|
165
165
|
:default: false
|
166
166
|
:description: Save standard output of the executed script
|
167
167
|
:env_var: MDE_SAVE_EXECUTION_OUTPUT
|
168
168
|
:long_name: save-execution-output
|
169
169
|
:opt_name: save_execution_output
|
170
|
-
:
|
170
|
+
:procname: val_as_bool
|
171
171
|
- :arg_name: INT
|
172
172
|
:default: 493
|
173
173
|
:description: chmod for saved scripts
|
174
174
|
:env_var: MDE_SAVED_SCRIPT_CHMOD
|
175
175
|
:opt_name: saved_script_chmod
|
176
|
-
:
|
176
|
+
:procname: val_as_int
|
177
177
|
- :arg_name: PREFIX
|
178
178
|
:default: mde
|
179
179
|
:description: Name prefix for saved scripts
|
180
180
|
:env_var: MDE_SAVED_SCRIPT_FILENAME_PREFIX
|
181
181
|
:opt_name: saved_script_filename_prefix
|
182
|
-
:
|
182
|
+
:procname: val_as_str
|
183
183
|
- :arg_name: RELATIVE_PATH
|
184
184
|
:default: logs
|
185
185
|
:description: Saved script folder
|
186
186
|
:env_var: MDE_SAVED_SCRIPT_FOLDER
|
187
187
|
:long_name: saved-script-folder
|
188
188
|
:opt_name: saved_script_folder
|
189
|
-
:
|
189
|
+
:procname: val_as_str
|
190
190
|
- :arg_name: GLOB
|
191
191
|
:default: mde_*.sh
|
192
192
|
:description: Glob matching saved scripts
|
193
193
|
:env_var: MDE_SAVED_SCRIPT_GLOB
|
194
194
|
:opt_name: saved_script_glob
|
195
|
-
:
|
195
|
+
:procname: val_as_str
|
196
196
|
- :arg_name: RELATIVE_PATH
|
197
197
|
:default: logs
|
198
198
|
:description: Saved stdout folder
|
199
199
|
:env_var: MDE_SAVED_STDOUT_FOLDER
|
200
200
|
:long_name: saved-stdout-folder
|
201
201
|
:opt_name: saved_stdout_folder
|
202
|
-
:
|
202
|
+
:procname: val_as_str
|
203
203
|
- :arg_name: GLOB
|
204
204
|
:default: mde_*.out.txt
|
205
205
|
:description: Glob matching saved outputs
|
206
206
|
:env_var: MDE_SAVED_STDOUT_GLOB
|
207
207
|
:opt_name: saved_stdout_glob
|
208
|
-
:
|
208
|
+
:procname: val_as_str
|
209
209
|
- :default: "^[\\(\\[].*[\\)\\]]$"
|
210
210
|
:description: Pattern for blocks to hide from user-selection
|
211
|
-
:env_var:
|
212
|
-
:opt_name:
|
213
|
-
:
|
211
|
+
:env_var: MDE_BLOCK_NAME_HIDDEN_MATCH
|
212
|
+
:opt_name: block_name_hidden_match
|
213
|
+
:procname: val_as_str
|
214
214
|
- :default: ":(?<title>\\S+)( |$)"
|
215
215
|
:env_var: MDE_BLOCK_NAME_MATCH
|
216
216
|
:opt_name: block_name_match
|
217
|
-
:
|
217
|
+
:procname: val_as_str
|
218
218
|
- :default: "%\\([^\\)]+\\)"
|
219
219
|
:env_var: MDE_BLOCK_CALLS_SCAN
|
220
220
|
:opt_name: block_calls_scan
|
221
|
-
:
|
221
|
+
:procname: val_as_str
|
222
222
|
- :default: "\\+\\S+"
|
223
223
|
:env_var: MDE_BLOCK_REQUIRED_SCAN
|
224
224
|
:opt_name: block_required_scan
|
225
|
-
:
|
225
|
+
:procname: val_as_str
|
226
226
|
- :default: "<(?<full>(?<type>\\$)?(?<name>[A-Za-z]\\S*))"
|
227
227
|
:env_var: MDE_BLOCK_STDIN_SCAN
|
228
228
|
:opt_name: block_stdin_scan
|
229
|
-
:
|
229
|
+
:procname: val_as_str
|
230
230
|
- :default: ">(?<full>(?<type>\\$)?(?<name>[A-Za-z]\\S*))"
|
231
231
|
:env_var: MDE_BLOCK_STDOUT_SCAN
|
232
232
|
:opt_name: block_stdout_scan
|
233
|
-
:
|
233
|
+
:procname: val_as_str
|
234
234
|
- :default: "> "
|
235
235
|
:env_var: MDE_DISPLAY_LEVEL_XBASE_PREFIX
|
236
236
|
:opt_name: display_level_xbase_prefix
|
237
|
-
:
|
237
|
+
:procname: val_as_str
|
238
238
|
- :default: "^`{3,}"
|
239
239
|
:env_var: MDE_FENCED_START_AND_END_MATCH
|
240
240
|
:opt_name: fenced_start_and_end_match
|
241
|
-
:
|
241
|
+
:procname: val_as_str
|
242
242
|
- :default: "^`{3,}(?<shell>[^`\\s]*) *(?<name>.*)$"
|
243
243
|
:env_var: MDE_FENCED_START_EX_MATCH
|
244
244
|
:opt_name: fenced_start_ex_match
|
245
|
-
:
|
245
|
+
:procname: val_as_str
|
246
246
|
- :default: "^# *(?<name>[^#]*?) *$"
|
247
247
|
:env_var: MDE_HEADING1_MATCH
|
248
248
|
:opt_name: heading1_match
|
249
|
-
:
|
249
|
+
:procname: val_as_str
|
250
250
|
- :default: "^## *(?<name>[^#]*?) *$"
|
251
251
|
:env_var: MDE_HEADING2_MATCH
|
252
252
|
:opt_name: heading2_match
|
253
|
-
:
|
253
|
+
:procname: val_as_str
|
254
254
|
- :default: "^### *(?<name>.+?) *$"
|
255
255
|
:env_var: MDE_HEADING3_MATCH
|
256
256
|
:opt_name: heading3_match
|
257
|
-
:
|
257
|
+
:procname: val_as_str
|
258
258
|
- :default: "*.[Mm][Dd]"
|
259
259
|
:env_var: MDE_MD_FILENAME_GLOB
|
260
260
|
:opt_name: md_filename_glob
|
261
|
-
:
|
261
|
+
:procname: val_as_str
|
262
262
|
- :default: ".+\\.md"
|
263
263
|
:env_var: MDE_MD_FILENAME_MATCH
|
264
264
|
:opt_name: md_filename_match
|
265
|
-
:
|
265
|
+
:procname: val_as_str
|
266
|
+
- :default: "-:= %s =:-"
|
267
|
+
:description: format for menu dividers and demarcations
|
268
|
+
:env_var: MDE_MENU_DIVIDER_FORMAT
|
269
|
+
:opt_name: menu_divider_format
|
270
|
+
:procname: val_as_str
|
271
|
+
- :default: magenta
|
272
|
+
:description: Color of menu divider
|
273
|
+
:env_var: MDE_MENU_DIVIDER_COLOR
|
274
|
+
:opt_name: menu_divider_color
|
275
|
+
:procname: val_as_str
|
266
276
|
- :default: "^::: +(?<name>.+?)$"
|
267
277
|
:description: Pattern for topics/dividers in block selection menu
|
268
278
|
:env_var: MDE_MENU_DIVIDER_MATCH
|
269
279
|
:opt_name: menu_divider_match
|
270
|
-
:
|
280
|
+
:procname: val_as_str
|
281
|
+
- :default: ">"
|
282
|
+
:description: Symbol before each divider
|
283
|
+
:env_var: MDE_MENU_DIVIDER_SYMBOL
|
284
|
+
:opt_name: menu_divider_symbol
|
285
|
+
:procname: val_as_str
|
286
|
+
- :default: "~~~"
|
287
|
+
:description: closing demarcations for menu
|
288
|
+
:env_var: MDE_MENU_FINAL_DIVIDER
|
289
|
+
:opt_name: menu_final_divider
|
290
|
+
:procname: val_as_str
|
291
|
+
- :default: ''
|
292
|
+
:description: opening demarcation for menu
|
293
|
+
:env_var: MDE_MENU_INITIAL_DIVIDER
|
294
|
+
:opt_name: menu_initial_divider
|
295
|
+
:procname: val_as_str
|
271
296
|
- :description: Options for viewing saved output file
|
272
297
|
:env_var: MDE_OUTPUT_VIEWER_OPTIONS
|
273
298
|
:opt_name: output_viewer_options
|
274
|
-
:
|
275
|
-
- :default:
|
299
|
+
:procname: val_as_str
|
300
|
+
- :default: 36
|
276
301
|
:description: 'Maximum # of rows in select list'
|
277
302
|
:env_var: MDE_SELECT_PAGE_HEIGHT
|
278
303
|
:opt_name: select_page_height
|
279
|
-
:
|
304
|
+
:procname: val_as_int
|
280
305
|
- :default: "#!/usr/bin/env"
|
281
306
|
:description: Shebang for saved scripts
|
282
307
|
:env_var: MDE_SHEBANG
|
283
308
|
:opt_name: shebang
|
284
|
-
:
|
309
|
+
:procname: val_as_str
|
285
310
|
- :default: bash
|
286
311
|
:description: Shell for launched scripts
|
287
312
|
:env_var: MDE_SHELL
|
288
313
|
:opt_name: shell
|
289
|
-
:
|
290
|
-
- :default:
|
291
|
-
:
|
292
|
-
:
|
293
|
-
:
|
314
|
+
:procname: val_as_str
|
315
|
+
- :default: Process?
|
316
|
+
:description: Prompt to approve a block
|
317
|
+
:env_var: MDE_PROMPT_APPROVE_BLOCK
|
318
|
+
:opt_name: prompt_approve_block
|
319
|
+
:procname: val_as_str
|
320
|
+
- :default: 'Choose a block:'
|
321
|
+
:description: Prompt to select a block
|
322
|
+
:env_var: MDE_PROMPT_SELECT_BLOCK
|
323
|
+
:opt_name: prompt_select_block
|
324
|
+
:procname: val_as_str
|
325
|
+
- :default: 'Choose a file:'
|
326
|
+
:description: Prompt to select a markdown document
|
327
|
+
:env_var: MDE_PROMPT_SELECT_MD
|
328
|
+
:opt_name: prompt_select_md
|
329
|
+
:procname: val_as_str
|
330
|
+
- :default: 'Choose a file:'
|
331
|
+
:description: Prompt to select a saved file
|
332
|
+
:env_var: MDE_PROMPT_SELECT_OUTPUT
|
333
|
+
:opt_name: prompt_select_output
|
334
|
+
:procname: val_as_str
|
335
|
+
- :default: Copy script to clipboard
|
336
|
+
:description: Prompt to copy script to clipboard
|
337
|
+
:env_var: MDE_PROMPT_SCRIPT_TO_CLIPBOARD
|
338
|
+
:opt_name: prompt_script_to_clipboard
|
339
|
+
:procname: val_as_str
|
340
|
+
- :default: Save script
|
341
|
+
:description: Prompt to save script
|
342
|
+
:env_var: MDE_PROMPT_SAVE_SCRIPT
|
343
|
+
:opt_name: prompt_save_script
|
344
|
+
:procname: val_as_str
|
345
|
+
- :default: 'No'
|
346
|
+
:description: Prompt for no
|
347
|
+
:env_var: MDE_PROMPT_NO
|
348
|
+
:opt_name: prompt_no
|
349
|
+
:procname: val_as_str
|
350
|
+
- :default: 'Yes'
|
351
|
+
:description: Prompt for yes
|
352
|
+
:env_var: MDE_PROMPT_YES
|
353
|
+
:opt_name: prompt_yes
|
354
|
+
:procname: val_as_str
|
355
|
+
- :default: " #=#=#"
|
356
|
+
:description: Output divider
|
357
|
+
:env_var: MDE_OUTPUT_DIVIDER
|
358
|
+
:opt_name: output_divider
|
359
|
+
:procname: val_as_str
|
360
|
+
- :default: yellow
|
361
|
+
:description: Color of output divider
|
362
|
+
:env_var: MDE_OUTPUT_DIVIDER_COLOR
|
363
|
+
:opt_name: output_divider_color
|
364
|
+
:procname: val_as_str
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# encoding=utf-8
|
4
|
+
|
5
|
+
# is the value empty?
|
6
|
+
#
|
7
|
+
class String
|
8
|
+
unless defined?(blank?)
|
9
|
+
def blank?
|
10
|
+
empty? || /\A[[:space:]]*\z/.freeze.match?(self)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# is the value non-empty?
|
16
|
+
#
|
17
|
+
class String
|
18
|
+
unless defined?(present?)
|
19
|
+
def present?
|
20
|
+
!empty?
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
# is the value a non-empty string or a binary?
|
27
|
+
#
|
28
|
+
# :reek:ManualDispatch ### temp
|
29
|
+
class Object
|
30
|
+
unless defined?(present?)
|
31
|
+
def present?
|
32
|
+
case self.class.to_s
|
33
|
+
when 'FalseClass', 'TrueClass'
|
34
|
+
true
|
35
|
+
else
|
36
|
+
self && (!respond_to?(:blank?) || !blank?)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/shared.rb
CHANGED
@@ -10,10 +10,11 @@ BF = 'bin'
|
|
10
10
|
|
11
11
|
# display_level values
|
12
12
|
DISPLAY_LEVEL_BASE = 0 # required output
|
13
|
-
DISPLAY_LEVEL_ADMIN = 1
|
13
|
+
DISPLAY_LEVEL_ADMIN = 1 # monit
|
14
14
|
DISPLAY_LEVEL_DEBUG = 2
|
15
|
+
DISPLAY_LEVEL_DUMP = 3
|
15
16
|
DISPLAY_LEVEL_DEFAULT = DISPLAY_LEVEL_ADMIN
|
16
|
-
DISPLAY_LEVEL_MAX =
|
17
|
+
DISPLAY_LEVEL_MAX = DISPLAY_LEVEL_DUMP
|
17
18
|
|
18
19
|
# @execute_files[ind] = @execute_files[ind] + [block]
|
19
20
|
EF_STDOUT = 0
|
@@ -26,15 +27,3 @@ MENU_YML = "lib/#{LOCAL_YML}"
|
|
26
27
|
def menu_from_yaml
|
27
28
|
YAML.load File.open(File.join(File.expand_path(__dir__), LOCAL_YML))
|
28
29
|
end
|
29
|
-
|
30
|
-
# skip :reek:UtilityFunction
|
31
|
-
def value_for_cli(value)
|
32
|
-
case value.class.to_s
|
33
|
-
when 'String'
|
34
|
-
Shellwords.escape value
|
35
|
-
when 'FalseClass', 'TrueClass'
|
36
|
-
value ? '1' : '0'
|
37
|
-
else
|
38
|
-
Shellwords.escape value.to_s
|
39
|
-
end
|
40
|
-
end
|
data/lib/tap.rb
CHANGED
@@ -11,32 +11,87 @@ include Env
|
|
11
11
|
## application-level debug control
|
12
12
|
#
|
13
13
|
module Tap
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
14
|
+
DN = 'return'
|
15
|
+
NONE = 0x0
|
16
|
+
T1 = 1 # RESULT
|
17
|
+
T2 = 2 # CONTEXT
|
18
|
+
T3 = 4 # MONITOR
|
19
|
+
T4 = 8 # DUMP
|
20
|
+
ALL2 = 0x77
|
21
|
+
ALL = 0xFF
|
22
|
+
TDD = 0x11
|
23
|
+
TB1 = 0x22
|
24
|
+
TB2 = 0x44
|
25
|
+
TB3 = 0x88
|
26
|
+
TD = 0x0F
|
27
|
+
TD0 = 0x01
|
28
|
+
TD1 = 0x02
|
29
|
+
TD2 = 0x04
|
30
|
+
TP = 0xF0
|
31
|
+
TP0 = 0x10
|
32
|
+
TP1 = 0x20
|
33
|
+
TP2 = 0x40
|
34
|
+
|
35
|
+
# cast with message per tap_inspect type
|
36
|
+
# type: message
|
37
|
+
#
|
38
|
+
CVT = {
|
39
|
+
json: :to_json,
|
40
|
+
string: :to_s,
|
41
|
+
yaml: :to_yaml,
|
42
|
+
else: :inspect
|
43
|
+
}.freeze
|
44
|
+
|
45
|
+
$tap_enable = false
|
46
|
+
$tap_mask = ALL2
|
47
|
+
|
48
|
+
def tap_config(enable: true, envvar: nil, value: nil)
|
49
|
+
$tap_enable = false
|
50
|
+
if envvar
|
51
|
+
$tap_enable = (env_int envvar).positive?
|
52
|
+
$tap_mask = ALL2 if $tap_enable
|
53
|
+
elsif value
|
54
|
+
$tap_mask = value.to_i
|
55
|
+
$tap_enable = $tap_mask.positive?
|
56
|
+
elsif enable
|
57
|
+
$tap_mask = ALL2
|
58
|
+
$tap_enable = true
|
59
|
+
end
|
60
|
+
# puts "$tap_enable: #{$tap_enable}"
|
61
|
+
# puts "$tap_mask: #{$tap_mask.to_s(2)}"
|
24
62
|
end
|
25
63
|
|
26
|
-
def tap_inspect(
|
64
|
+
def tap_inspect(name_ = nil, caller0: nil, mask: TDD, name: DN, source: nil, type: nil)
|
27
65
|
return self unless $tap_enable
|
66
|
+
return self unless (mask & $tap_mask).positive?
|
28
67
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
fn = cvt.fetch(format, cvt[:else])
|
36
|
-
|
37
|
-
puts "-> #{caller[0].scan(/in `?(\S+)'$/)[0][0]}()" \
|
38
|
-
" #{name}: #{method(fn).call}"
|
68
|
+
fn = CVT.fetch(type, CVT[:else])
|
69
|
+
outs = []
|
70
|
+
outs.push("#{source}") if source
|
71
|
+
outs.push("#{(caller0 || caller[0]).scan(/in `?(\S+)'$/)[0][0]}()") # if (mask & $tap_mask & TP).positive?
|
72
|
+
outs.push("#{name_ || name}: #{method(fn).call}") # if (mask & $tap_mask & TD).positive?
|
73
|
+
puts outs.join(' ') if outs.length.positive?
|
39
74
|
|
40
75
|
self
|
41
76
|
end
|
77
|
+
|
78
|
+
def tap_print(mask: TDD)
|
79
|
+
return self unless (mask & $tap_mask).positive?
|
80
|
+
|
81
|
+
print self
|
82
|
+
end
|
83
|
+
|
84
|
+
def tap_puts(name_ = nil, caller0: nil, mask: TDD, name: nil, type: nil)
|
85
|
+
# return self unless (mask & $tap_mask).positive?
|
86
|
+
|
87
|
+
if (name1 = name_ || name).present?
|
88
|
+
puts "#{name1}: #{self}"
|
89
|
+
else
|
90
|
+
puts self
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def tap_yaml(name_ = nil, caller0: nil, mask: TDD, name: DN, source: nil)
|
95
|
+
tap_inspect name_, caller0: (caller0 || caller[0]), mask: mask, name: name, source: source, type: :yaml
|
96
|
+
end
|
42
97
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: markdown_exec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fareed Stevenson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clipboard
|
@@ -110,12 +110,15 @@ files:
|
|
110
110
|
- bin/setup
|
111
111
|
- bin/tab_completion.sh
|
112
112
|
- bin/tab_completion.sh.erb
|
113
|
+
- lib/cli.rb
|
113
114
|
- lib/colorize.rb
|
114
115
|
- lib/env.rb
|
116
|
+
- lib/environment_opt_parse.rb
|
115
117
|
- lib/globfiles.rb
|
116
118
|
- lib/markdown_exec.rb
|
117
119
|
- lib/markdown_exec/version.rb
|
118
120
|
- lib/menu.yml
|
121
|
+
- lib/object_present.rb
|
119
122
|
- lib/shared.rb
|
120
123
|
- lib/tap.rb
|
121
124
|
homepage: https://rubygems.org/gems/markdown_exec
|