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,248 @@
|
|
|
1
|
+
# Block Scanning Pattern Options
|
|
2
|
+
|
|
3
|
+
This document describes the configuration options that control how markdown_exec scans block content for special patterns and directives.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Block scanning patterns are regex patterns used to extract special information from fenced code blocks. These patterns identify:
|
|
8
|
+
- Call names in block start lines
|
|
9
|
+
- Required dependencies in block bodies
|
|
10
|
+
- Stdin/stdout redirections
|
|
11
|
+
- Default block types
|
|
12
|
+
- Format strings for special block types
|
|
13
|
+
|
|
14
|
+
## Configuration Options
|
|
15
|
+
|
|
16
|
+
### block_calls_scan
|
|
17
|
+
|
|
18
|
+
- **Option**: `block_calls_scan`
|
|
19
|
+
- **Environment Variable**: `MDE_BLOCK_CALLS_SCAN`
|
|
20
|
+
- **Default**: `"%\\([^\\)]+\\)"`
|
|
21
|
+
- **Description**: Regex pattern to extract call names from block start lines (e.g., %call_name)
|
|
22
|
+
|
|
23
|
+
This pattern is used to extract call names from the fenced code block start line. When a block has a call name like `%my_call`, this pattern matches it and extracts `my_call` for use in block execution and dependency tracking.
|
|
24
|
+
|
|
25
|
+
**Example:**
|
|
26
|
+
```markdown
|
|
27
|
+
```bash :my_block %my_call
|
|
28
|
+
echo "This block has a call name"
|
|
29
|
+
```
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
The pattern `%\\([^\\)]+\\)` matches `%my_call` and extracts `my_call` as the call name.
|
|
33
|
+
|
|
34
|
+
### block_required_scan
|
|
35
|
+
|
|
36
|
+
- **Option**: `block_required_scan`
|
|
37
|
+
- **Environment Variable**: `MDE_BLOCK_REQUIRED_SCAN`
|
|
38
|
+
- **Default**: `"\\+\\S+"`
|
|
39
|
+
- **Description**: Regex pattern to scan block body for required dependencies (e.g., +blockname)
|
|
40
|
+
|
|
41
|
+
This pattern scans the block body content to identify required dependencies. When a block contains text like `+dependency_name`, it indicates that the block depends on another block named `dependency_name`.
|
|
42
|
+
|
|
43
|
+
**Example:**
|
|
44
|
+
```markdown
|
|
45
|
+
```bash :my_block
|
|
46
|
+
# This block requires another block
|
|
47
|
+
+setup_block
|
|
48
|
+
+config_block
|
|
49
|
+
echo "Running after dependencies"
|
|
50
|
+
```
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
The pattern `\\+\\S+` matches `+setup_block` and `+config_block`, indicating these blocks must be executed before `my_block`.
|
|
54
|
+
|
|
55
|
+
### block_stdin_scan
|
|
56
|
+
|
|
57
|
+
- **Option**: `block_stdin_scan`
|
|
58
|
+
- **Environment Variable**: `MDE_BLOCK_STDIN_SCAN`
|
|
59
|
+
- **Default**: `"<(?<full>(?<type>\\$)?(?<name>[A-Za-z_\\-\\.\\w]+))"`
|
|
60
|
+
- **Description**: Regex pattern to scan block body for stdin redirection (e.g., <variable or <$variable)
|
|
61
|
+
|
|
62
|
+
This pattern identifies stdin redirection directives in block content. It matches patterns like `<variable` or `<$variable` to indicate that the block should read from a variable or file.
|
|
63
|
+
|
|
64
|
+
**Example:**
|
|
65
|
+
```markdown
|
|
66
|
+
```bash :my_block
|
|
67
|
+
# Read from a variable
|
|
68
|
+
<$input_data
|
|
69
|
+
process_data
|
|
70
|
+
```
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
The pattern matches `<input_data` or `<$input_data` and extracts the variable name for stdin redirection.
|
|
74
|
+
|
|
75
|
+
### block_stdout_scan
|
|
76
|
+
|
|
77
|
+
- **Option**: `block_stdout_scan`
|
|
78
|
+
- **Environment Variable**: `MDE_BLOCK_STDOUT_SCAN`
|
|
79
|
+
- **Default**: `">(?<full>(?<type>\\$)?(?<name>[A-Za-z_\\-\\.\\w]+))"`
|
|
80
|
+
- **Description**: Match to place block body into a file or a variable
|
|
81
|
+
|
|
82
|
+
This pattern identifies stdout redirection directives in block content. It matches patterns like `>variable` or `>$variable` to indicate where the block's output should be directed.
|
|
83
|
+
|
|
84
|
+
**Example:**
|
|
85
|
+
```markdown
|
|
86
|
+
```bash :my_block
|
|
87
|
+
# Write output to a variable
|
|
88
|
+
generate_data >output_var
|
|
89
|
+
```
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
The pattern matches `>output_var` or `>$output_var` and extracts the variable name for stdout redirection.
|
|
93
|
+
|
|
94
|
+
### block_type_default
|
|
95
|
+
|
|
96
|
+
- **Option**: `block_type_default`
|
|
97
|
+
- **Environment Variable**: `MDE_BLOCK_TYPE_DEFAULT`
|
|
98
|
+
- **Default**: `bash`
|
|
99
|
+
- **Description**: Default shell type for blocks when no type is specified in the fenced code block
|
|
100
|
+
|
|
101
|
+
When a fenced code block doesn't specify a type (e.g., just ` ``` ` instead of ` ```bash `), this option determines the default shell type to use for execution.
|
|
102
|
+
|
|
103
|
+
**Example:**
|
|
104
|
+
```markdown
|
|
105
|
+
```
|
|
106
|
+
echo "This uses the default shell type"
|
|
107
|
+
```
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
If `block_type_default` is set to `bash`, this block will be executed as a bash script.
|
|
111
|
+
|
|
112
|
+
**Valid values:**
|
|
113
|
+
- `bash` - Bash shell (default)
|
|
114
|
+
- `sh` - POSIX shell
|
|
115
|
+
- `fish` - Fish shell
|
|
116
|
+
|
|
117
|
+
### block_type_port_set_format
|
|
118
|
+
|
|
119
|
+
- **Option**: `block_type_port_set_format`
|
|
120
|
+
- **Environment Variable**: `MDE_BLOCK_TYPE_PORT_SET_FORMAT`
|
|
121
|
+
- **Default**: `": ${%{key}:=%{value}}"`
|
|
122
|
+
- **Description**: Format string for generating shell variable assignments from PORT block content
|
|
123
|
+
|
|
124
|
+
This format string is used when processing PORT-type blocks to generate shell commands that set environment variables. The format uses placeholders:
|
|
125
|
+
- `%{key}` - The variable name
|
|
126
|
+
- `%{value}` - The variable value
|
|
127
|
+
|
|
128
|
+
**Example:**
|
|
129
|
+
```markdown
|
|
130
|
+
```port
|
|
131
|
+
PATH HOME USER
|
|
132
|
+
```
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
With the default format `": ${%{key}:=%{value}}"`, this would generate:
|
|
136
|
+
```bash
|
|
137
|
+
: ${PATH:=/usr/bin:/bin}
|
|
138
|
+
: ${HOME:=/home/user}
|
|
139
|
+
: ${USER:=username}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
The format uses shell parameter expansion syntax (`${VAR:=default}`) to set variables with default values if they're not already set.
|
|
143
|
+
|
|
144
|
+
## How It Works
|
|
145
|
+
|
|
146
|
+
### Scanning Process
|
|
147
|
+
|
|
148
|
+
1. **Start Line Scanning**: When a fenced code block is parsed, `block_calls_scan` is applied to the start line to extract call names.
|
|
149
|
+
|
|
150
|
+
2. **Body Content Scanning**: After parsing the block body, the following patterns are applied:
|
|
151
|
+
- `block_required_scan` - Scans for dependency markers
|
|
152
|
+
- `block_stdin_scan` - Scans for stdin redirection
|
|
153
|
+
- `block_stdout_scan` - Scans for stdout redirection
|
|
154
|
+
|
|
155
|
+
3. **Type Determination**: If no type is specified in the fenced code block delimiter, `block_type_default` is used.
|
|
156
|
+
|
|
157
|
+
4. **PORT Block Processing**: For PORT-type blocks, `block_type_port_set_format` is used to generate shell variable assignment commands.
|
|
158
|
+
|
|
159
|
+
### Execution Order
|
|
160
|
+
|
|
161
|
+
1. Block start line is parsed for call names
|
|
162
|
+
2. Block body is scanned for required dependencies
|
|
163
|
+
3. Block body is scanned for stdin/stdout redirections
|
|
164
|
+
4. Block type is determined (from delimiter or default)
|
|
165
|
+
5. For PORT blocks, format string is applied to generate commands
|
|
166
|
+
|
|
167
|
+
## Usage Examples
|
|
168
|
+
|
|
169
|
+
### Custom Call Pattern
|
|
170
|
+
|
|
171
|
+
To use a different call pattern (e.g., `@call_name` instead of `%call_name`):
|
|
172
|
+
|
|
173
|
+
```yaml
|
|
174
|
+
block_calls_scan: "@\\([^\\)]+\\)"
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### Custom Required Dependency Pattern
|
|
178
|
+
|
|
179
|
+
To use a different dependency marker (e.g., `requires:blockname`):
|
|
180
|
+
|
|
181
|
+
```yaml
|
|
182
|
+
block_required_scan: "requires:(\\S+)"
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Custom Default Shell Type
|
|
186
|
+
|
|
187
|
+
To use `sh` as the default instead of `bash`:
|
|
188
|
+
|
|
189
|
+
```yaml
|
|
190
|
+
block_type_default: sh
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Custom PORT Format
|
|
194
|
+
|
|
195
|
+
To use a different format for PORT blocks (e.g., simple assignment):
|
|
196
|
+
|
|
197
|
+
```yaml
|
|
198
|
+
block_type_port_set_format: "export %{key}=%{value}"
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
This would generate:
|
|
202
|
+
```bash
|
|
203
|
+
export PATH=/usr/bin:/bin
|
|
204
|
+
export HOME=/home/user
|
|
205
|
+
export USER=username
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
## Related Configuration
|
|
209
|
+
|
|
210
|
+
These options work together with:
|
|
211
|
+
|
|
212
|
+
- **Block Naming Patterns** (`block_name_match`, `block_name_nick_match`, etc.) - Control how block names are extracted
|
|
213
|
+
- **Block Execution Modes** (`block_batch_match`, `block_interactive_match`) - Control how blocks are executed
|
|
214
|
+
- **Block Filtering** (`exclude_by_name_regex`, `select_by_name_regex`) - Control which blocks are included/excluded
|
|
215
|
+
|
|
216
|
+
## Technical Details
|
|
217
|
+
|
|
218
|
+
### Pattern Matching
|
|
219
|
+
|
|
220
|
+
All scan patterns use Ruby regex syntax. Special characters must be escaped:
|
|
221
|
+
- `\\(` for literal `(`
|
|
222
|
+
- `\\)` for literal `)`
|
|
223
|
+
- `\\+` for literal `+`
|
|
224
|
+
- `\\$` for literal `$`
|
|
225
|
+
|
|
226
|
+
### Named Capture Groups
|
|
227
|
+
|
|
228
|
+
Some patterns use named capture groups:
|
|
229
|
+
- `block_stdin_scan` captures `full`, `type`, and `name`
|
|
230
|
+
- `block_stdout_scan` captures `full`, `type`, and `name`
|
|
231
|
+
|
|
232
|
+
These capture groups allow the code to extract specific parts of the matched pattern.
|
|
233
|
+
|
|
234
|
+
### Default Values
|
|
235
|
+
|
|
236
|
+
The default patterns are designed to match common conventions:
|
|
237
|
+
- `%call_name` for call names
|
|
238
|
+
- `+dependency` for required dependencies
|
|
239
|
+
- `<variable` for stdin redirection
|
|
240
|
+
- `>variable` for stdout redirection
|
|
241
|
+
|
|
242
|
+
## Related Documentation
|
|
243
|
+
|
|
244
|
+
- [Block Naming Patterns](block-naming-patterns.md) - How block names are parsed and matched
|
|
245
|
+
- [Block Execution Modes](block-execution-modes.md) - How blocks are executed
|
|
246
|
+
- [Block Filtering](block-filtering.md) - How blocks are filtered and selected
|
|
247
|
+
- [CLI Reference](cli-reference.md) - Command-line usage
|
|
248
|
+
|
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
# CLI Reference
|
|
2
|
+
|
|
3
|
+
Quick reference for command-line usage of MarkdownExec. For detailed option documentation, see the specialized guides linked below.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
MarkdownExec provides both interactive and command-line modes for executing code blocks from markdown documents. Most options can be specified via:
|
|
8
|
+
- Command-line flags (e.g., `--filename`, `-f`)
|
|
9
|
+
- Environment variables (e.g., `MDE_FILENAME`)
|
|
10
|
+
- Configuration files (`.mde.yml`)
|
|
11
|
+
|
|
12
|
+
## Basic Usage
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
# Interactive mode - process README.md in current directory
|
|
16
|
+
mde
|
|
17
|
+
|
|
18
|
+
# Process a specific markdown file
|
|
19
|
+
mde my-document.md
|
|
20
|
+
|
|
21
|
+
# Execute a specific block directly (non-interactive)
|
|
22
|
+
mde my-document.md my-block-name
|
|
23
|
+
|
|
24
|
+
# Execute a specific block using option flag
|
|
25
|
+
mde my-document.md --block-name my-block-name
|
|
26
|
+
mde my-document.md -b my-block-name
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## File and Document Selection
|
|
30
|
+
|
|
31
|
+
### `filename` / `-f`
|
|
32
|
+
|
|
33
|
+
- **Option**: `filename`
|
|
34
|
+
- **Long Name**: `--filename`
|
|
35
|
+
- **Short Name**: `-f`
|
|
36
|
+
- **Environment Variable**: `MDE_FILENAME`
|
|
37
|
+
- **Default**: None
|
|
38
|
+
|
|
39
|
+
Specifies which markdown file to process. Can be a relative path to a markdown file.
|
|
40
|
+
|
|
41
|
+
**Usage:**
|
|
42
|
+
```bash
|
|
43
|
+
mde --filename my-document.md
|
|
44
|
+
mde -f my-document.md
|
|
45
|
+
mde my-document.md # Positional argument (position 0)
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
**Note**: If a filename is provided as a positional argument (first argument without a flag), it's automatically treated as the filename.
|
|
49
|
+
|
|
50
|
+
### `path` / `-p`
|
|
51
|
+
|
|
52
|
+
- **Option**: `path`
|
|
53
|
+
- **Long Name**: `--path`
|
|
54
|
+
- **Short Name**: `-p`
|
|
55
|
+
- **Environment Variable**: `MDE_PATH`
|
|
56
|
+
- **Default**: `"."`
|
|
57
|
+
|
|
58
|
+
Specifies the directory path where markdown documents are located.
|
|
59
|
+
|
|
60
|
+
**Usage:**
|
|
61
|
+
```bash
|
|
62
|
+
mde --path /path/to/documents
|
|
63
|
+
mde -p ./docs
|
|
64
|
+
mde /path/to/documents # Positional argument if directory exists
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### `block-name` / `-b`
|
|
68
|
+
|
|
69
|
+
- **Option**: `block_name`
|
|
70
|
+
- **Long Name**: `--block-name`
|
|
71
|
+
- **Short Name**: `-b`
|
|
72
|
+
- **Environment Variable**: `MDE_BLOCK_NAME`
|
|
73
|
+
- **Default**: None
|
|
74
|
+
|
|
75
|
+
Specifies which code block to execute directly, bypassing the interactive menu.
|
|
76
|
+
|
|
77
|
+
**Usage:**
|
|
78
|
+
```bash
|
|
79
|
+
mde my-document.md --block-name my-block
|
|
80
|
+
mde my-document.md -b my-block
|
|
81
|
+
mde my-document.md my-block # Positional argument (position 1)
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
**Note**: If a block name is provided as a positional argument (second argument), it's automatically treated as the block name. Use `.` as the block name to force menu display.
|
|
85
|
+
|
|
86
|
+
### `hide-shebang`
|
|
87
|
+
|
|
88
|
+
- **Option**: `hide_shebang`
|
|
89
|
+
- **Long Name**: `--hide-shebang` / `--no-hide-shebang`
|
|
90
|
+
- **Environment Variable**: `MDE_HIDE_SHEBANG`
|
|
91
|
+
- **Default**: `true`
|
|
92
|
+
|
|
93
|
+
Controls whether shebang lines (lines starting with `#!`) are hidden from document output. When enabled (default), shebang lines are extracted from input files during processing and not displayed as part of the document. This is useful when markdown files include shebang lines for direct execution (e.g., `#!/usr/bin/env mde`) but you don't want them to appear in the rendered document.
|
|
94
|
+
|
|
95
|
+
**Usage:**
|
|
96
|
+
```bash
|
|
97
|
+
# Hide shebang lines (default behavior)
|
|
98
|
+
mde my-document.md
|
|
99
|
+
mde my-document.md --hide-shebang
|
|
100
|
+
MDE_HIDE_SHEBANG=true mde my-document.md
|
|
101
|
+
|
|
102
|
+
# Show shebang lines in output
|
|
103
|
+
mde my-document.md --no-hide-shebang
|
|
104
|
+
MDE_HIDE_SHEBANG=false mde my-document.md
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
**Note**: The option applies to both the main document and any imported files (via `@import` directives). Shebang lines are detected and filtered during the cached nested read process.
|
|
108
|
+
|
|
109
|
+
## Discovery Commands
|
|
110
|
+
|
|
111
|
+
### `list-blocks`
|
|
112
|
+
|
|
113
|
+
- **Option**: `list_blocks`
|
|
114
|
+
- **Long Name**: `--list-blocks`
|
|
115
|
+
|
|
116
|
+
Displays all available code blocks in the specified document(s). Useful for discovering what blocks are available without entering interactive mode.
|
|
117
|
+
|
|
118
|
+
**Usage:**
|
|
119
|
+
```bash
|
|
120
|
+
mde my-document.md --list-blocks
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### `list-docs`
|
|
124
|
+
|
|
125
|
+
- **Option**: `list_docs`
|
|
126
|
+
- **Long Name**: `--list-docs`
|
|
127
|
+
|
|
128
|
+
Lists all markdown documents found in the current directory (or specified path).
|
|
129
|
+
|
|
130
|
+
**Usage:**
|
|
131
|
+
```bash
|
|
132
|
+
mde --list-docs
|
|
133
|
+
mde --path /path/to/docs --list-docs
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### `find` / `?`
|
|
137
|
+
|
|
138
|
+
- **Option**: `find`
|
|
139
|
+
- **Long Name**: `--find`
|
|
140
|
+
- **Short Name**: `?`
|
|
141
|
+
|
|
142
|
+
Searches for a keyword or pattern across markdown documents, block names, and file contents. Displays matching results and allows selection.
|
|
143
|
+
|
|
144
|
+
**Usage:**
|
|
145
|
+
```bash
|
|
146
|
+
mde --find "search-term"
|
|
147
|
+
mde ? "search-term"
|
|
148
|
+
mde "search-term" # Positional argument if file doesn't exist
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### `open` / `o`
|
|
152
|
+
|
|
153
|
+
- **Option**: `open`
|
|
154
|
+
- **Long Name**: `--open`
|
|
155
|
+
- **Short Name**: `o`
|
|
156
|
+
|
|
157
|
+
Similar to `find`, but automatically presents a selection menu and opens the user's choice. Combines search and open in one step.
|
|
158
|
+
|
|
159
|
+
**Usage:**
|
|
160
|
+
```bash
|
|
161
|
+
mde --open "search-term"
|
|
162
|
+
mde -o "search-term"
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## Save Options
|
|
166
|
+
|
|
167
|
+
### `save-executed-script`
|
|
168
|
+
|
|
169
|
+
- **Option**: `save_executed_script`
|
|
170
|
+
- **Long Name**: `--save-executed-script`
|
|
171
|
+
- **Environment Variable**: `MDE_SAVE_EXECUTED_SCRIPT`
|
|
172
|
+
- **Default**: `false`
|
|
173
|
+
|
|
174
|
+
When enabled, saves the generated script to a file before execution. Scripts are saved with timestamps and metadata for later review or replay.
|
|
175
|
+
|
|
176
|
+
**Usage:**
|
|
177
|
+
```bash
|
|
178
|
+
mde my-document.md --save-executed-script 1
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
**Saved Script Location:**
|
|
182
|
+
- Default folder: `logs/` (configurable via `saved_script_folder`)
|
|
183
|
+
- Filename format: `mde_TIMESTAMP_DOCUMENT~BLOCK.sh` (configurable via `saved_asset_format`)
|
|
184
|
+
|
|
185
|
+
### `save-execution-output`
|
|
186
|
+
|
|
187
|
+
- **Option**: `save_execution_output`
|
|
188
|
+
- **Long Name**: `--save-execution-output`
|
|
189
|
+
- **Environment Variable**: `MDE_SAVE_EXECUTION_OUTPUT`
|
|
190
|
+
- **Default**: `false`
|
|
191
|
+
|
|
192
|
+
When enabled, saves the standard output (stdout) from script execution to a file. Useful for logging execution results.
|
|
193
|
+
|
|
194
|
+
**Usage:**
|
|
195
|
+
```bash
|
|
196
|
+
mde my-document.md --save-execution-output 1
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
## Utility Commands
|
|
200
|
+
|
|
201
|
+
### `help` / `-h`
|
|
202
|
+
|
|
203
|
+
- **Option**: `help`
|
|
204
|
+
- **Long Name**: `--help`
|
|
205
|
+
- **Short Name**: `-h`
|
|
206
|
+
|
|
207
|
+
Displays the help message with usage information and available options.
|
|
208
|
+
|
|
209
|
+
**Usage:**
|
|
210
|
+
```bash
|
|
211
|
+
mde --help
|
|
212
|
+
mde -h
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### `version` / `-v`
|
|
216
|
+
|
|
217
|
+
- **Option**: `version`
|
|
218
|
+
- **Long Name**: `--version`
|
|
219
|
+
- **Short Name**: `-v`
|
|
220
|
+
|
|
221
|
+
Displays the current version of MarkdownExec.
|
|
222
|
+
|
|
223
|
+
**Usage:**
|
|
224
|
+
```bash
|
|
225
|
+
mde --version
|
|
226
|
+
mde -v
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### `debug` / `-d`
|
|
230
|
+
|
|
231
|
+
- **Option**: `debug`
|
|
232
|
+
- **Long Name**: `--debug`
|
|
233
|
+
- **Short Name**: `-d`
|
|
234
|
+
- **Environment Variable**: `MDE_DEBUG`
|
|
235
|
+
- **Default**: `false`
|
|
236
|
+
|
|
237
|
+
Enables debug output, providing detailed information about internal operations, option parsing, and execution flow. Useful for troubleshooting.
|
|
238
|
+
|
|
239
|
+
**Usage:**
|
|
240
|
+
```bash
|
|
241
|
+
mde my-document.md --debug 1
|
|
242
|
+
mde my-document.md -d 1
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
### `config`
|
|
246
|
+
|
|
247
|
+
- **Option**: `config`
|
|
248
|
+
- **Long Name**: `--config`
|
|
249
|
+
- **Default**: `"."`
|
|
250
|
+
|
|
251
|
+
Specifies the path to a configuration file (`.mde.yml`). Configuration files allow you to set default options for a project or directory.
|
|
252
|
+
|
|
253
|
+
**Usage:**
|
|
254
|
+
```bash
|
|
255
|
+
mde --config /path/to/.mde.yml
|
|
256
|
+
mde --config .
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
**Note**: Configuration files are automatically loaded from the current directory (`.mde.yml`) if they exist. Use `--config` to specify a different location.
|
|
260
|
+
|
|
261
|
+
### `exit` / `x`
|
|
262
|
+
|
|
263
|
+
- **Option**: `exit`
|
|
264
|
+
- **Long Name**: `--exit`
|
|
265
|
+
- **Short Name**: `x`
|
|
266
|
+
|
|
267
|
+
Exits the application immediately. Useful in scripts or when you want to exit without processing.
|
|
268
|
+
|
|
269
|
+
**Usage:**
|
|
270
|
+
```bash
|
|
271
|
+
mde --exit
|
|
272
|
+
mde -x
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
### `load-code` / `l`
|
|
276
|
+
|
|
277
|
+
- **Option**: `load_code`
|
|
278
|
+
- **Long Name**: `--load-code`
|
|
279
|
+
- **Short Name**: `l`
|
|
280
|
+
- **Environment Variable**: `MDE_LOAD_CODE`
|
|
281
|
+
|
|
282
|
+
Loads code from an external file into the document context. The loaded code is treated as inherited lines that can be referenced by blocks.
|
|
283
|
+
|
|
284
|
+
**Usage:**
|
|
285
|
+
```bash
|
|
286
|
+
mde my-document.md --load-code /path/to/code.sh
|
|
287
|
+
mde my-document.md -l /path/to/code.sh
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
## Common Usage Patterns
|
|
291
|
+
|
|
292
|
+
### Quick Execution
|
|
293
|
+
|
|
294
|
+
```bash
|
|
295
|
+
# Execute a specific block directly
|
|
296
|
+
mde README.md deploy
|
|
297
|
+
|
|
298
|
+
# With approval (see execution-control.md for details)
|
|
299
|
+
mde README.md deploy --user-must-approve 1
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
### Interactive Development
|
|
303
|
+
|
|
304
|
+
```bash
|
|
305
|
+
# Open document in interactive mode
|
|
306
|
+
mde README.md
|
|
307
|
+
|
|
308
|
+
# Open with specific block pre-selected
|
|
309
|
+
mde README.md --block-name .
|
|
310
|
+
|
|
311
|
+
# Search and open
|
|
312
|
+
mde --open "setup"
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
### Script Management
|
|
316
|
+
|
|
317
|
+
```bash
|
|
318
|
+
# Save scripts and output
|
|
319
|
+
mde README.md -b deploy --save-executed-script 1 --save-execution-output 1
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
### Discovery and Exploration
|
|
323
|
+
|
|
324
|
+
```bash
|
|
325
|
+
# List available documents
|
|
326
|
+
mde --list-docs
|
|
327
|
+
|
|
328
|
+
# List blocks in a document
|
|
329
|
+
mde README.md --list-blocks
|
|
330
|
+
|
|
331
|
+
# Search for content
|
|
332
|
+
mde --find "database"
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
## Configuration
|
|
336
|
+
|
|
337
|
+
### Environment Variables
|
|
338
|
+
|
|
339
|
+
All options can be set via environment variables using the `MDE_` prefix:
|
|
340
|
+
|
|
341
|
+
```bash
|
|
342
|
+
export MDE_FILENAME=README.md
|
|
343
|
+
export MDE_SAVE_EXECUTED_SCRIPT=1
|
|
344
|
+
export MDE_DEBUG=1
|
|
345
|
+
|
|
346
|
+
mde -b deploy
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
### Configuration Files
|
|
350
|
+
|
|
351
|
+
Create a `.mde.yml` file in your project directory to set default options:
|
|
352
|
+
|
|
353
|
+
```yaml
|
|
354
|
+
# .mde.yml
|
|
355
|
+
save_executed_script: true
|
|
356
|
+
user_must_approve: true
|
|
357
|
+
output_script: true
|
|
358
|
+
saved_script_folder: logs
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
## Related Documentation
|
|
362
|
+
|
|
363
|
+
- [Execution Control](execution-control.md) - Detailed execution control options (approval, window execution, pausing, debouncing)
|
|
364
|
+
- [Block Execution Modes](block-execution-modes.md) - Batch, interactive, and default execution modes
|
|
365
|
+
- [Block Filtering](block-filtering.md) - Filtering and selecting blocks
|
|
366
|
+
- [Block Naming Patterns](block-naming-patterns.md) - How block names are parsed and matched
|
|
367
|
+
- [Block Scanning Patterns](block-scanning-patterns.md) - How block content is scanned for patterns
|
|
368
|
+
- [Import Options](import-options.md) - @import directive configuration
|
|
369
|
+
- [UX Blocks](ux-blocks.md) - Interactive form blocks
|
|
370
|
+
|
data/docs/dev/block-hide.md
CHANGED
|
@@ -9,7 +9,7 @@ name: name
|
|
|
9
9
|
@import bats-document-configuration.md
|
|
10
10
|
```opts :(document_opts)
|
|
11
11
|
# Pattern for blocks to hide from user-selection
|
|
12
|
-
|
|
12
|
+
block_name_hidden_match:
|
|
13
13
|
^\(.*\)$
|
|
14
14
|
|
|
15
15
|
# Pattern for the block name in the line defining the block
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
exec: basename $(pwd)
|
|
5
5
|
name: Var0
|
|
6
6
|
```
|
|
7
|
-
$(
|
|
7
|
+
$(print_bytes "$Var0")
|
|
8
8
|
:::
|
|
9
9
|
**With validate and transform, output has no newline.**
|
|
10
10
|
```ux :[document_ux_transform_1]
|
|
@@ -13,7 +13,7 @@ name: Var1
|
|
|
13
13
|
transform: '%{name}'
|
|
14
14
|
validate: (?<name>.+)
|
|
15
15
|
```
|
|
16
|
-
$(
|
|
16
|
+
$(print_bytes "$Var1")
|
|
17
17
|
:::
|
|
18
18
|
**With transform `:chomp`, output has no newline.**
|
|
19
19
|
```ux :[document_ux_transform_2]
|
|
@@ -21,7 +21,7 @@ exec: basename $(pwd)
|
|
|
21
21
|
name: Var2
|
|
22
22
|
transform: :chomp
|
|
23
23
|
```
|
|
24
|
-
$(
|
|
24
|
+
$(print_bytes "$Var2")
|
|
25
25
|
:::
|
|
26
26
|
**With transform `:upcase`, output is in upper case w/ newline.**
|
|
27
27
|
```ux :[document_ux_transform_3]
|
|
@@ -29,8 +29,9 @@ exec: basename $(pwd)
|
|
|
29
29
|
name: Var3
|
|
30
30
|
transform: :upcase
|
|
31
31
|
```
|
|
32
|
-
$(
|
|
32
|
+
$(print_bytes "$Var3")
|
|
33
33
|
@import bats-document-configuration.md
|
|
34
|
+
@import print_bytes.md
|
|
34
35
|
```opts :(document_opts)
|
|
35
36
|
divider4_collapsible: false
|
|
36
37
|
screen_width: 80
|
data/docs/dev/shebang.md
ADDED
data/docs/docker-testing.md
CHANGED
|
@@ -83,6 +83,11 @@ docker run --rm markdown-exec-test bundle exec rake minitest
|
|
|
83
83
|
- **BATS Location**: `/markdown_exec/test/bats/bin/bats` (symlinked to `/usr/local/bin/bats`)
|
|
84
84
|
- **Test Helpers**: Located in `/markdown_exec/test/test_helper/`
|
|
85
85
|
|
|
86
|
+
## Related Documentation
|
|
87
|
+
|
|
88
|
+
- [Option Documentation Process](option-documentation-process.md) - Process for documenting options
|
|
89
|
+
- [Option Documentation Tasks](option-documentation-tasks.md) - Task list for documentation
|
|
90
|
+
|
|
86
91
|
## Troubleshooting
|
|
87
92
|
|
|
88
93
|
### Submodules not initialized
|