markdown_exec 3.5.1 → 3.5.2
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/.ai-agent-instructions +54 -0
- data/.cursorrules +198 -0
- data/.rubocop.wide.yml +5 -0
- data/.rubocop.yml +7 -2
- data/CHANGELOG.md +12 -1
- data/Gemfile.lock +1 -1
- data/Rakefile +2 -0
- data/ai-principles.md +516 -0
- data/architecture-decisions.md +190 -0
- data/bats/block-hide.bats +1 -1
- data/bats/block-type-bash.bats +5 -5
- data/bats/block-type-link.bats +1 -1
- data/bats/block-type-opts.bats +3 -3
- data/bats/block-type-port.bats +2 -2
- data/bats/block-type-shell-require-ux.bats +2 -2
- data/bats/block-type-ux-allowed.bats +4 -4
- data/bats/block-type-ux-auto.bats +1 -1
- data/bats/block-type-ux-chained.bats +1 -1
- data/bats/block-type-ux-default.bats +1 -1
- data/bats/block-type-ux-echo-hash-transform.bats +1 -1
- data/bats/block-type-ux-echo-hash.bats +2 -2
- data/bats/block-type-ux-echo.bats +3 -3
- data/bats/block-type-ux-exec-hash-transform.bats +1 -1
- data/bats/block-type-ux-exec-hash.bats +2 -2
- data/bats/block-type-ux-exec.bats +1 -1
- data/bats/block-type-ux-force.bats +1 -1
- data/bats/block-type-ux-formats.bats +1 -1
- data/bats/block-type-ux-hidden.bats +1 -1
- data/bats/block-type-ux-invalid.bats +1 -1
- data/bats/block-type-ux-readonly.bats +1 -1
- data/bats/block-type-ux-require-chained.bats +2 -2
- data/bats/block-type-ux-require-context.bats +2 -2
- data/bats/block-type-ux-require.bats +2 -2
- data/bats/block-type-ux-required-variables.bats +1 -1
- data/bats/block-type-ux-row-format.bats +1 -1
- data/bats/block-type-ux-sources.bats +4 -4
- data/bats/block-type-ux-transform.bats +1 -1
- data/bats/block-type-vars.bats +3 -3
- data/bats/border.bats +1 -1
- data/bats/cli.bats +11 -11
- data/bats/command-substitution-options.bats +2 -2
- data/bats/command-substitution.bats +1 -1
- data/bats/document-shell.bats +1 -1
- data/bats/history.bats +5 -5
- data/bats/import-conflict.bats +1 -1
- data/bats/import-directive-line-continuation.bats +1 -1
- data/bats/import-directive-parameter-symbols.bats +1 -1
- data/bats/import-duplicates.bats +6 -6
- data/bats/import-parameter-symbols.bats +1 -1
- data/bats/import-with-text-substitution.bats +1 -1
- data/bats/import.bats +3 -3
- data/bats/indented-block-type-vars.bats +1 -1
- data/bats/indented-multi-line-output.bats +1 -1
- data/bats/line-decor-dynamic.bats +1 -1
- data/bats/line-wrapping.bats +1 -1
- data/bats/load-vars-state-demo.bats +4 -4
- data/bats/markup.bats +4 -4
- data/bats/mde.bats +4 -4
- data/bats/option-expansion.bats +1 -1
- data/bats/options-collapse.bats +4 -4
- data/bats/options.bats +47 -17
- data/bats/plain.bats +1 -1
- data/bats/publish.bats +2 -2
- data/bats/table-column-truncate.bats +1 -1
- data/bats/table.bats +2 -2
- data/bats/variable-expansion-multiline.bats +1 -1
- data/bats/variable-expansion.bats +6 -6
- data/conversation-template.md +611 -0
- data/docs/block-execution-modes.md +177 -0
- data/docs/block-filtering.md +252 -0
- data/docs/block-naming-patterns.md +210 -0
- data/docs/block-scanning-patterns.md +248 -0
- data/docs/cli-reference.md +370 -0
- data/docs/dev/block-hide.md +1 -1
- data/docs/dev/block-type-ux-transform.md +5 -4
- data/docs/dev/print_bytes.md +3 -0
- data/docs/dev/shebang.md +6 -0
- data/docs/docker-testing.md +5 -0
- data/docs/execution-control.md +384 -0
- data/docs/getting-started.md +209 -0
- data/docs/import-options.md +391 -0
- data/docs/tab-completion.md +7 -0
- data/docs/ux-blocks.md +376 -0
- data/examples/linked1.md +8 -1
- data/implementation-decisions.md +212 -0
- data/lib/cached_nested_file_reader.rb +138 -1
- data/lib/command_result.rb +27 -6
- data/lib/executed_shell_command.rb +512 -0
- data/lib/filter.rb +7 -7
- data/lib/hash_delegator.rb +403 -350
- data/lib/link_history.rb +22 -11
- data/lib/markdown_exec/version.rb +1 -1
- data/lib/mdoc.rb +103 -44
- data/lib/menu.src.yml +110 -83
- data/lib/menu.yml +149 -83
- data/lib/transformed_shell_command.rb +449 -0
- data/lib/wl.rb +15 -0
- data/lib/ww.rb +16 -5
- data/requirements.md +111 -0
- data/semantic-tokens.md +132 -0
- data/tasks.md +69 -0
- metadata +26 -4
- data/docs/ux-blocks-examples.md +0 -120
- data/docs/ux-blocks-init-act.md +0 -100
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
# Execution Control Options
|
|
2
|
+
|
|
3
|
+
This document describes options that control how scripts are executed, including approval requirements, execution modes, and flow control.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Execution control options allow you to:
|
|
8
|
+
- Require user approval before executing scripts
|
|
9
|
+
- Control where scripts execute (current terminal vs. new window)
|
|
10
|
+
- Pause execution flow for review
|
|
11
|
+
- Prevent accidental re-execution of the same block
|
|
12
|
+
- Display scripts before execution
|
|
13
|
+
|
|
14
|
+
These options provide safety and control mechanisms for script execution, especially useful when working with potentially destructive operations or when you need to review scripts before they run.
|
|
15
|
+
|
|
16
|
+
## Configuration Options
|
|
17
|
+
|
|
18
|
+
### `user-must-approve` / `-q`
|
|
19
|
+
|
|
20
|
+
- **Option**: `user_must_approve`
|
|
21
|
+
- **Long Name**: `--user-must-approve`
|
|
22
|
+
- **Short Name**: `-q`
|
|
23
|
+
- **Environment Variable**: `MDE_USER_MUST_APPROVE`
|
|
24
|
+
- **Argument**: `BOOL`
|
|
25
|
+
- **Default**: `false`
|
|
26
|
+
- **Description**: Requires user approval before executing a script
|
|
27
|
+
|
|
28
|
+
When enabled, displays the complete generated script (including all required dependencies) and prompts the user for confirmation before execution. This is a critical safety feature for reviewing scripts before they run.
|
|
29
|
+
|
|
30
|
+
**Usage:**
|
|
31
|
+
```bash
|
|
32
|
+
mde my-document.md --user-must-approve 1
|
|
33
|
+
mde my-document.md -q 1
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
**Examples:**
|
|
37
|
+
```bash
|
|
38
|
+
# Require approval for all executions
|
|
39
|
+
mde README.md -b deploy --user-must-approve 1
|
|
40
|
+
|
|
41
|
+
# Set via environment variable
|
|
42
|
+
export MDE_USER_MUST_APPROVE=1
|
|
43
|
+
mde README.md -b deploy
|
|
44
|
+
|
|
45
|
+
# In configuration file
|
|
46
|
+
# .mde.yml
|
|
47
|
+
user_must_approve: true
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**Behavior:**
|
|
51
|
+
- The full script (including all required dependencies) is displayed
|
|
52
|
+
- User is prompted with "Process?" (configurable via `prompt_approve_block`)
|
|
53
|
+
- Execution only proceeds if user confirms (Yes/No)
|
|
54
|
+
- Works in both interactive menu mode and command-line mode
|
|
55
|
+
- When combined with `output_script`, the script is displayed regardless
|
|
56
|
+
|
|
57
|
+
**Related Options:**
|
|
58
|
+
- `output_script`: Display script before execution (doesn't require approval)
|
|
59
|
+
- `prompt_approve_block`: Customize the approval prompt text
|
|
60
|
+
|
|
61
|
+
### `execute-in-own-window` / `-w`
|
|
62
|
+
|
|
63
|
+
- **Option**: `execute_in_own_window`
|
|
64
|
+
- **Long Name**: `--execute-in-own-window`
|
|
65
|
+
- **Short Name**: `-w`
|
|
66
|
+
- **Environment Variable**: `MDE_EXECUTE_IN_OWN_WINDOW`
|
|
67
|
+
- **Argument**: `BOOL`
|
|
68
|
+
- **Default**: `false`
|
|
69
|
+
- **Description**: Execute script in own window
|
|
70
|
+
|
|
71
|
+
When enabled, executes the script in a new terminal window (iTerm on macOS) instead of the current terminal. Useful for long-running scripts or when you want to keep the main terminal free for other operations.
|
|
72
|
+
|
|
73
|
+
**Usage:**
|
|
74
|
+
```bash
|
|
75
|
+
mde my-document.md --execute-in-own-window 1
|
|
76
|
+
mde my-document.md -w 1
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
**Examples:**
|
|
80
|
+
```bash
|
|
81
|
+
# Execute in new window
|
|
82
|
+
mde README.md -b long-running-task -w 1
|
|
83
|
+
|
|
84
|
+
# Combine with approval
|
|
85
|
+
mde README.md -b deploy -q 1 -w 1
|
|
86
|
+
|
|
87
|
+
# Set via environment variable
|
|
88
|
+
export MDE_EXECUTE_IN_OWN_WINDOW=1
|
|
89
|
+
mde README.md -b deploy
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
**Requirements:**
|
|
93
|
+
- Requires `execute_command_format` to be configured (defaults to AppleScript for iTerm on macOS)
|
|
94
|
+
- Script and output files must be saved before execution (handled automatically)
|
|
95
|
+
- Window title includes timestamp, document name, and block name
|
|
96
|
+
|
|
97
|
+
**Window Title Format:**
|
|
98
|
+
The window title uses `execute_command_title_time_format` (default: `"%T"`) and includes:
|
|
99
|
+
- Timestamp (formatted)
|
|
100
|
+
- Document filename
|
|
101
|
+
- Block name
|
|
102
|
+
|
|
103
|
+
**Customization:**
|
|
104
|
+
For other terminal emulators or platforms, customize `execute_command_format` to use different commands or scripts.
|
|
105
|
+
|
|
106
|
+
**Related Options:**
|
|
107
|
+
- `execute_command_format`: AppleScript or command template for window execution
|
|
108
|
+
- `execute_command_title_time_format`: Time format for window title
|
|
109
|
+
|
|
110
|
+
### `output-script`
|
|
111
|
+
|
|
112
|
+
- **Option**: `output_script`
|
|
113
|
+
- **Long Name**: `--output-script`
|
|
114
|
+
- **Environment Variable**: `MDE_OUTPUT_SCRIPT`
|
|
115
|
+
- **Argument**: `BOOL`
|
|
116
|
+
- **Default**: `false`
|
|
117
|
+
- **Description**: Display script prior to execution
|
|
118
|
+
|
|
119
|
+
When enabled, displays the generated script (including all required dependencies) before execution, even if `user_must_approve` is disabled. Useful for debugging, reviewing what will be executed, or logging.
|
|
120
|
+
|
|
121
|
+
**Usage:**
|
|
122
|
+
```bash
|
|
123
|
+
mde my-document.md --output-script 1
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
**Examples:**
|
|
127
|
+
```bash
|
|
128
|
+
# Display script before execution
|
|
129
|
+
mde README.md -b deploy --output-script 1
|
|
130
|
+
|
|
131
|
+
# Combine with approval for review
|
|
132
|
+
mde README.md -b deploy --output-script 1 --user-must-approve 1
|
|
133
|
+
|
|
134
|
+
# Set via environment variable
|
|
135
|
+
export MDE_OUTPUT_SCRIPT=1
|
|
136
|
+
mde README.md -b deploy
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
**Behavior:**
|
|
140
|
+
- Script is displayed with frame markers (configurable via `script_preview_head` and `script_preview_tail`)
|
|
141
|
+
- Includes all required dependencies in execution order
|
|
142
|
+
- Execution proceeds automatically (unless `user_must_approve` is also enabled)
|
|
143
|
+
- Useful for debugging or understanding what will execute
|
|
144
|
+
|
|
145
|
+
**Related Options:**
|
|
146
|
+
- `user_must_approve`: Require approval after displaying script
|
|
147
|
+
- `script_preview_head`: Text displayed before script preview
|
|
148
|
+
- `script_preview_tail`: Text displayed after script preview
|
|
149
|
+
- `script_preview_frame_color`: Color for preview frame
|
|
150
|
+
|
|
151
|
+
### `debounce-execution`
|
|
152
|
+
|
|
153
|
+
- **Option**: `debounce_execution`
|
|
154
|
+
- **Environment Variable**: `MDE_DEBOUNCE_EXECUTION`
|
|
155
|
+
- **Argument**: `BOOL`
|
|
156
|
+
- **Default**: `true`
|
|
157
|
+
- **Description**: Whether to prompt before re-executing the same block multiple times
|
|
158
|
+
|
|
159
|
+
When enabled, prevents accidental re-execution of the same block by prompting for confirmation if you try to execute a block that was just executed. This helps prevent accidental duplicate executions.
|
|
160
|
+
|
|
161
|
+
**Usage:**
|
|
162
|
+
```bash
|
|
163
|
+
# Via environment variable (no CLI flag)
|
|
164
|
+
export MDE_DEBOUNCE_EXECUTION=0 # Disable
|
|
165
|
+
export MDE_DEBOUNCE_EXECUTION=1 # Enable (default)
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
**Examples:**
|
|
169
|
+
```bash
|
|
170
|
+
# Disable debouncing (allow immediate re-execution)
|
|
171
|
+
export MDE_DEBOUNCE_EXECUTION=0
|
|
172
|
+
mde README.md
|
|
173
|
+
|
|
174
|
+
# Enable debouncing (default behavior)
|
|
175
|
+
export MDE_DEBOUNCE_EXECUTION=1
|
|
176
|
+
mde README.md
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
**Behavior:**
|
|
180
|
+
- When enabled, if you select the same block that was just executed, you're prompted with "Repeat this block?" (configurable via `prompt_debounce`)
|
|
181
|
+
- Blocks executed from CLI (via `--block-name`) bypass debouncing
|
|
182
|
+
- Debounce state is reset when navigating back or selecting different menu options
|
|
183
|
+
- Only applies to interactive menu selections, not CLI-specified blocks
|
|
184
|
+
|
|
185
|
+
**Related Options:**
|
|
186
|
+
- `prompt_debounce`: Customize the debounce prompt text
|
|
187
|
+
|
|
188
|
+
### `pause-after-script-execution`
|
|
189
|
+
|
|
190
|
+
- **Option**: `pause_after_script_execution`
|
|
191
|
+
- **Long Name**: `--pause-after-script-execution`
|
|
192
|
+
- **Environment Variable**: `MDE_PAUSE_AFTER_SCRIPT_EXECUTION`
|
|
193
|
+
- **Argument**: `BOOL`
|
|
194
|
+
- **Default**: `false`
|
|
195
|
+
- **Description**: Whether to pause after manually executing a block and before the next menu
|
|
196
|
+
|
|
197
|
+
When enabled, pauses execution after a block completes and before displaying the next menu. Useful for reviewing execution results before continuing.
|
|
198
|
+
|
|
199
|
+
**Usage:**
|
|
200
|
+
```bash
|
|
201
|
+
mde my-document.md --pause-after-script-execution 1
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
**Examples:**
|
|
205
|
+
```bash
|
|
206
|
+
# Pause after execution
|
|
207
|
+
mde README.md -b deploy --pause-after-script-execution 1
|
|
208
|
+
|
|
209
|
+
# Set via environment variable
|
|
210
|
+
export MDE_PAUSE_AFTER_SCRIPT_EXECUTION=1
|
|
211
|
+
mde README.md -b deploy
|
|
212
|
+
|
|
213
|
+
# In configuration file
|
|
214
|
+
# .mde.yml
|
|
215
|
+
pause_after_script_execution: true
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
**Behavior:**
|
|
219
|
+
- After script execution completes, displays the prompt (configurable via `prompt_after_script_execution`, default: "\nContinue?")
|
|
220
|
+
- User must press Enter or respond to continue
|
|
221
|
+
- Useful for reviewing execution output before the menu reappears
|
|
222
|
+
- Works in interactive mode
|
|
223
|
+
|
|
224
|
+
**Related Options:**
|
|
225
|
+
- `prompt_after_script_execution`: Customize the pause prompt text
|
|
226
|
+
- `prompt_color_after_script_execution`: Color for the pause prompt
|
|
227
|
+
|
|
228
|
+
### `execute-command-format`
|
|
229
|
+
|
|
230
|
+
- **Option**: `execute_command_format`
|
|
231
|
+
- **Environment Variable**: `MDE_EXECUTE_COMMAND_FORMAT`
|
|
232
|
+
- **Default**: AppleScript template for iTerm
|
|
233
|
+
- **Description**: AppleScript to execute a command in a window
|
|
234
|
+
|
|
235
|
+
Template string used when `execute_in_own_window` is enabled. The default is an AppleScript that creates a new iTerm window and executes the script there.
|
|
236
|
+
|
|
237
|
+
**Usage:**
|
|
238
|
+
```bash
|
|
239
|
+
# Set via environment variable
|
|
240
|
+
export MDE_EXECUTE_COMMAND_FORMAT='your-custom-template'
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
**Default Template:**
|
|
244
|
+
The default template uses AppleScript to:
|
|
245
|
+
1. Create a new iTerm window
|
|
246
|
+
2. Set environment variables for script and output files
|
|
247
|
+
3. Change to the working directory
|
|
248
|
+
4. Set the window title
|
|
249
|
+
5. Execute the script with output redirected to a log file
|
|
250
|
+
|
|
251
|
+
**Customization:**
|
|
252
|
+
For other terminal emulators or platforms, customize this template to use different commands. The template supports format placeholders:
|
|
253
|
+
- `%{batch_index}`: Batch index
|
|
254
|
+
- `%{home}`: Working directory
|
|
255
|
+
- `%{output_filespec}`: Output file path
|
|
256
|
+
- `%{script_filespec}`: Script file path
|
|
257
|
+
- `%{started_at}`: Execution start time
|
|
258
|
+
- `%{document_filename}`: Document filename
|
|
259
|
+
- `%{block_name}`: Block name
|
|
260
|
+
- `%{rest}`: Additional arguments
|
|
261
|
+
|
|
262
|
+
**Related Options:**
|
|
263
|
+
- `execute_in_own_window`: Enable window execution
|
|
264
|
+
- `execute_command_title_time_format`: Time format for window title
|
|
265
|
+
|
|
266
|
+
### `execute-command-title-time-format`
|
|
267
|
+
|
|
268
|
+
- **Option**: `execute_command_title_time_format`
|
|
269
|
+
- **Environment Variable**: `MDE_EXECUTE_COMMAND_TITLE_TIME_FORMAT`
|
|
270
|
+
- **Default**: `"%T"`
|
|
271
|
+
- **Description**: Format for time in window title
|
|
272
|
+
|
|
273
|
+
Time format string used in the window title when `execute_in_own_window` is enabled. Uses Ruby `Time#strftime` format.
|
|
274
|
+
|
|
275
|
+
**Usage:**
|
|
276
|
+
```bash
|
|
277
|
+
# Set via environment variable
|
|
278
|
+
export MDE_EXECUTE_COMMAND_TITLE_TIME_FORMAT="%H:%M:%S"
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
**Examples:**
|
|
282
|
+
```bash
|
|
283
|
+
# 24-hour time
|
|
284
|
+
export MDE_EXECUTE_COMMAND_TITLE_TIME_FORMAT="%H:%M:%S"
|
|
285
|
+
|
|
286
|
+
# Full timestamp
|
|
287
|
+
export MDE_EXECUTE_COMMAND_TITLE_TIME_FORMAT="%Y-%m-%d %H:%M:%S"
|
|
288
|
+
|
|
289
|
+
# ISO 8601
|
|
290
|
+
export MDE_EXECUTE_COMMAND_TITLE_TIME_FORMAT="%FT%TZ"
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
**Common Format Codes:**
|
|
294
|
+
- `%H`: Hour (00-23)
|
|
295
|
+
- `%M`: Minute (00-59)
|
|
296
|
+
- `%S`: Second (00-59)
|
|
297
|
+
- `%Y`: Year (4 digits)
|
|
298
|
+
- `%m`: Month (01-12)
|
|
299
|
+
- `%d`: Day (01-31)
|
|
300
|
+
- `%T`: Time (equivalent to `%H:%M:%S`)
|
|
301
|
+
- `%F`: Date (equivalent to `%Y-%m-%d`)
|
|
302
|
+
|
|
303
|
+
## How It Works
|
|
304
|
+
|
|
305
|
+
### Execution Flow
|
|
306
|
+
|
|
307
|
+
1. **Script Generation**: The complete script is generated, including all required dependencies
|
|
308
|
+
2. **Display Check**: If `output_script` or `user_must_approve` is enabled, the script is displayed
|
|
309
|
+
3. **Approval Check**: If `user_must_approve` is enabled, user confirmation is required
|
|
310
|
+
4. **Execution Mode**: Script executes either:
|
|
311
|
+
- In current terminal (default)
|
|
312
|
+
- In new window (if `execute_in_own_window` is enabled)
|
|
313
|
+
5. **Post-Execution**: If `pause_after_script_execution` is enabled, execution pauses before menu
|
|
314
|
+
|
|
315
|
+
### Debouncing Logic
|
|
316
|
+
|
|
317
|
+
The debouncing mechanism tracks the last executed block:
|
|
318
|
+
- If the same block is selected again, user is prompted
|
|
319
|
+
- Blocks executed from CLI bypass debouncing
|
|
320
|
+
- Debounce state resets on navigation or different block selection
|
|
321
|
+
|
|
322
|
+
### Window Execution
|
|
323
|
+
|
|
324
|
+
When `execute_in_own_window` is enabled:
|
|
325
|
+
1. Script is saved to a temporary file
|
|
326
|
+
2. Output file path is determined
|
|
327
|
+
3. `execute_command_format` template is populated with values
|
|
328
|
+
4. Template is executed (typically AppleScript for iTerm)
|
|
329
|
+
5. New window opens and executes the script
|
|
330
|
+
|
|
331
|
+
## Usage Examples
|
|
332
|
+
|
|
333
|
+
### Safe Execution with Approval
|
|
334
|
+
|
|
335
|
+
```bash
|
|
336
|
+
# Require approval for all executions
|
|
337
|
+
mde README.md -b deploy --user-must-approve 1
|
|
338
|
+
|
|
339
|
+
# Or set globally
|
|
340
|
+
export MDE_USER_MUST_APPROVE=1
|
|
341
|
+
mde README.md -b deploy
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
### Review Script Before Execution
|
|
345
|
+
|
|
346
|
+
```bash
|
|
347
|
+
# Display script and require approval
|
|
348
|
+
mde README.md -b deploy --output-script 1 --user-must-approve 1
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
### Long-Running Scripts in New Window
|
|
352
|
+
|
|
353
|
+
```bash
|
|
354
|
+
# Execute in new window
|
|
355
|
+
mde README.md -b long-task --execute-in-own-window 1
|
|
356
|
+
|
|
357
|
+
# With approval
|
|
358
|
+
mde README.md -b long-task -q 1 -w 1
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
### Pause After Execution
|
|
362
|
+
|
|
363
|
+
```bash
|
|
364
|
+
# Pause to review results
|
|
365
|
+
mde README.md -b deploy --pause-after-script-execution 1
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
### Configuration File Example
|
|
369
|
+
|
|
370
|
+
```yaml
|
|
371
|
+
# .mde.yml
|
|
372
|
+
user_must_approve: true
|
|
373
|
+
output_script: true
|
|
374
|
+
pause_after_script_execution: true
|
|
375
|
+
execute_in_own_window: false
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
## Related Documentation
|
|
379
|
+
|
|
380
|
+
- [CLI Reference](cli-reference.md) - Command-line usage patterns
|
|
381
|
+
- [Block Execution Modes](block-execution-modes.md) - Batch, interactive, and default execution modes
|
|
382
|
+
- [Block Filtering](block-filtering.md) - Filtering and selecting blocks
|
|
383
|
+
- [Block Naming Patterns](block-naming-patterns.md) - How block names are parsed and matched
|
|
384
|
+
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
# Getting Started with MarkdownExec
|
|
2
|
+
|
|
3
|
+
A quick guide to get you up and running with MarkdownExec.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
gem install markdown_exec
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
### Interactive Mode (Recommended)
|
|
14
|
+
|
|
15
|
+
The simplest way to use MarkdownExec is in interactive mode:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# Process README.md in current directory
|
|
19
|
+
mde
|
|
20
|
+
|
|
21
|
+
# Process a specific markdown file
|
|
22
|
+
mde my-document.md
|
|
23
|
+
|
|
24
|
+
# Select from markdown files in current folder
|
|
25
|
+
mde .
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Command Line Mode
|
|
29
|
+
|
|
30
|
+
Execute specific blocks directly without the interactive menu:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
# Execute a specific block
|
|
34
|
+
mde my-document.md my-block-name
|
|
35
|
+
|
|
36
|
+
# Or use the flag
|
|
37
|
+
mde my-document.md --block-name my-block-name
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Basic Concepts
|
|
41
|
+
|
|
42
|
+
### Named Code Blocks
|
|
43
|
+
|
|
44
|
+
Create executable code blocks with names:
|
|
45
|
+
|
|
46
|
+
```bash :setup
|
|
47
|
+
echo "Setting up environment"
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
The block name (`setup`) is extracted from the fenced code block start line.
|
|
51
|
+
|
|
52
|
+
### Block Dependencies
|
|
53
|
+
|
|
54
|
+
Blocks can require other blocks to run first:
|
|
55
|
+
|
|
56
|
+
```bash :deploy +setup +test
|
|
57
|
+
echo "Deploying after setup and test"
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
The `+setup` and `+test` indicate that those blocks must execute first.
|
|
61
|
+
|
|
62
|
+
### Interactive Forms (UX Blocks)
|
|
63
|
+
|
|
64
|
+
Create interactive forms for user input:
|
|
65
|
+
|
|
66
|
+
```ux
|
|
67
|
+
name: USER_NAME
|
|
68
|
+
prompt: Enter your name
|
|
69
|
+
init: Guest
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Cross-Document Navigation
|
|
73
|
+
|
|
74
|
+
Navigate between documents while maintaining context:
|
|
75
|
+
|
|
76
|
+
```link
|
|
77
|
+
file: next-document.md
|
|
78
|
+
vars:
|
|
79
|
+
current_user: ${USER_NAME}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Common Usage Patterns
|
|
83
|
+
|
|
84
|
+
### Quick Execution
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
# Execute a specific block directly
|
|
88
|
+
mde README.md deploy
|
|
89
|
+
|
|
90
|
+
# With approval (review script before execution)
|
|
91
|
+
mde README.md deploy --user-must-approve 1
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Interactive Development
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
# Open document in interactive mode
|
|
98
|
+
mde README.md
|
|
99
|
+
|
|
100
|
+
# Search and open a document
|
|
101
|
+
mde --open "setup"
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Discovery
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
# List available documents
|
|
108
|
+
mde --list-docs
|
|
109
|
+
|
|
110
|
+
# List blocks in a document
|
|
111
|
+
mde README.md --list-blocks
|
|
112
|
+
|
|
113
|
+
# Search for content
|
|
114
|
+
mde --find "database"
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Script Management
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
# Save scripts and output
|
|
121
|
+
mde README.md -b deploy --save-executed-script 1 --save-execution-output 1
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Configuration
|
|
125
|
+
|
|
126
|
+
### Environment Variables
|
|
127
|
+
|
|
128
|
+
Set options via environment variables:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
export MDE_USER_MUST_APPROVE=1
|
|
132
|
+
export MDE_SAVE_EXECUTED_SCRIPT=1
|
|
133
|
+
mde README.md deploy
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Configuration Files
|
|
137
|
+
|
|
138
|
+
Create a `.mde.yml` file in your project:
|
|
139
|
+
|
|
140
|
+
```yaml
|
|
141
|
+
# .mde.yml
|
|
142
|
+
save_executed_script: true
|
|
143
|
+
user_must_approve: true
|
|
144
|
+
output_script: true
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Next Steps
|
|
148
|
+
|
|
149
|
+
- [CLI Reference](cli-reference.md) - Complete command-line reference
|
|
150
|
+
- [Execution Control](execution-control.md) - Control how scripts execute
|
|
151
|
+
- [Block Execution Modes](block-execution-modes.md) - Configure execution modes
|
|
152
|
+
- [Block Filtering](block-filtering.md) - Filter and select blocks
|
|
153
|
+
- [UX Blocks](ux-blocks.md) - Interactive form system
|
|
154
|
+
- [Import Options](import-options.md) - Template system with @import
|
|
155
|
+
- [Tab Completion](tab-completion.md) - Set up tab completion
|
|
156
|
+
|
|
157
|
+
## Example Workflow
|
|
158
|
+
|
|
159
|
+
Here's a complete example demonstrating key features:
|
|
160
|
+
|
|
161
|
+
### Step 1: User Input
|
|
162
|
+
|
|
163
|
+
```ux :user-setup
|
|
164
|
+
name: USER_NAME
|
|
165
|
+
prompt: Enter your name
|
|
166
|
+
init: Guest
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
```ux :environment
|
|
170
|
+
name: ENVIRONMENT
|
|
171
|
+
allow:
|
|
172
|
+
- development
|
|
173
|
+
- staging
|
|
174
|
+
- production
|
|
175
|
+
prompt: Select environment
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Step 2: Automated Setup
|
|
179
|
+
|
|
180
|
+
```bash :setup +user-setup +environment
|
|
181
|
+
echo "Setting up for user: ${USER_NAME}"
|
|
182
|
+
echo "Environment: ${ENVIRONMENT}"
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Step 3: Conditional Logic
|
|
186
|
+
|
|
187
|
+
```bash :deploy +setup
|
|
188
|
+
if [ "${ENVIRONMENT}" = "production" ]; then
|
|
189
|
+
echo "Deploying to production with extra safety checks"
|
|
190
|
+
else
|
|
191
|
+
echo "Deploying to ${ENVIRONMENT}"
|
|
192
|
+
fi
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### Step 4: Cross-Document Navigation
|
|
196
|
+
|
|
197
|
+
```link
|
|
198
|
+
file: next-workflow.md
|
|
199
|
+
vars:
|
|
200
|
+
user: ${USER_NAME}
|
|
201
|
+
env: ${ENVIRONMENT}
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
## Getting Help
|
|
205
|
+
|
|
206
|
+
- Run `mde --help` for command-line help
|
|
207
|
+
- See [CLI Reference](cli-reference.md) for detailed option documentation
|
|
208
|
+
- Check the [README](../README.md) for feature overview
|
|
209
|
+
|