markdown_exec 0.2.0 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -0
- data/CHANGELOG.md +103 -1
- data/Gemfile +2 -0
- data/Gemfile.lock +7 -1
- data/README.md +29 -34
- data/Rakefile +18 -6
- data/assets/approve_code.png +0 -0
- data/assets/example_blocks.png +0 -0
- data/assets/output_of_execution.png +0 -0
- data/assets/select_a_block.png +0 -0
- data/assets/select_a_file.png +0 -0
- data/fixtures/bash1.md +12 -0
- data/fixtures/bash2.md +15 -0
- data/fixtures/exclude1.md +6 -0
- data/fixtures/exclude2.md +9 -0
- data/fixtures/exec1.md +8 -0
- data/fixtures/heading1.md +19 -0
- data/fixtures/sample1.md +9 -0
- data/fixtures/title1.md +6 -0
- data/lib/markdown_exec/version.rb +1 -1
- data/lib/markdown_exec.rb +511 -230
- metadata +19 -10
- data/assets/approve.png +0 -0
- data/assets/blocks.png +0 -0
- data/assets/executed.png +0 -0
- data/assets/select.png +0 -0
- data/assets/select_file.png +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2336bb2091df5bf018181e832fb9c5e7a5b7ee542b6f71cde38a3afb3aa88ab4
|
4
|
+
data.tar.gz: '072654942ddf5897784c71724a7f9fa6fb5bea9b395d54ca18a3f3fd9b02c5af'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f28a18aea943a7fec92b16d232b8c3722a30f6960fbd32bf84e95762b4ac322f0fb53f75563118a15136da72e49f16c580a8c7fbf05d2001857e068403834ef
|
7
|
+
data.tar.gz: 8bb762715d790e37906d61cf8834e86dfe7e4f9611b8f7477da508d2ff658d496c6e1e0c89fc42e9e5f2cf937e29dae3cddf062cabda867f3a5bb1466986f2c3
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,106 @@
|
|
1
|
-
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
|
4
|
+
## [0.2.4] - 2022-04-01
|
5
|
+
|
6
|
+
### Added
|
7
|
+
|
8
|
+
- Command `--list-recent-scripts` to list the last *N* saved scripts.
|
9
|
+
- Command `--run-last-script` to re-run the last saved script.
|
10
|
+
- Command `--select-recent-script` to select and execute a recently saved script.
|
11
|
+
|
12
|
+
| YAML Name | Environment Variable | Option Name | Default | Purpose |
|
13
|
+
| :--- | :--- | :--- | :--- | :--- |
|
14
|
+
| list_count | MDE_LIST_COUNT | `--list_count` | `16` | Max. items to return in list |
|
15
|
+
| logged_stdout_filename_prefix | MDE_LOGGED_STDOUT_FILENAME_PREFIX | | `mde` | Name prefix for stdout files |
|
16
|
+
| save_execution_output | MDE_SAVE_EXECUTION_OUTPUT | `--save-execution-output` | False | Save standard output of the executed script |
|
17
|
+
| saved_script_filename_prefix | MDE_SAVED_SCRIPT_FILENAME_PREFIX | | `mde` | Name prefix for saved scripts |
|
18
|
+
| saved_script_folder | MDE_SAVED_SCRIPT_FOLDER | `--saved-script-folder` | `logs` | Saved script folder |
|
19
|
+
| saved_script_glob | MDE_SAVED_SCRIPT_GLOB | | `mde_*.sh` | Glob matching saved scripts |
|
20
|
+
| saved_stdout_folder | MDE_SAVED_STDOUT_FOLDER | `--saved-stdout-folder` | `logs` | Saved stdout folder |
|
21
|
+
|
22
|
+
### Changed
|
23
|
+
|
24
|
+
- Fix saving of executed script.
|
25
|
+
- Sort configuration keys output by `-0` (Show configuration.)
|
26
|
+
|
27
|
+
## [0.2.3] - 2022-03-29
|
28
|
+
|
29
|
+
### Added
|
30
|
+
|
31
|
+
- `rubocop` checks.
|
32
|
+
- Added optional command-line positional arguments:
|
33
|
+
1. document file
|
34
|
+
2. block name
|
35
|
+
|
36
|
+
e.g. `mde doc1 block1` will execute the block named `block1` in file `doc1`.
|
37
|
+
|
38
|
+
### Changed
|
39
|
+
|
40
|
+
- Naming saved script files: The file name contains the time stamp, document name, and block name.
|
41
|
+
- Renamed folder with fixtures.
|
42
|
+
- Command options:
|
43
|
+
|
44
|
+
| YAML Name | Environment Variable | Option Name | Default | Purpose |
|
45
|
+
| :--- | :--- | :--- | :--- | :--- |
|
46
|
+
| debug | MDE_DEBUG | `--debug` | False | Output debugging information (verbose) |
|
47
|
+
| filename | MDE_FILENAME | `--filename` | `README.md`* | File name of document |
|
48
|
+
| output_execution_summary | MDE_OUTPUT_STDOUT_SUMMARY | `--output-execution-summary` | False | Display summary for execution |
|
49
|
+
| output_script | MDE_OUTPUT_SCRIPT | `--output-script` | False | Display script |
|
50
|
+
| output_stdout | MDE_OUTPUT_EXECUTION | `--output-stdout` | True | Display standard output from execution |
|
51
|
+
| path | MDE_PATH | `--path` | `.` | Path to document(s) |
|
52
|
+
| save_executed_script | MDE_SAVE_EXECUTED_SCRIPT | `--save-executed-script` | False | Save executed script |
|
53
|
+
| saved_script_folder | MDE_SAVED_SCRIPT_FOLDER | `--saved-script-folder` | `logs` | Saved script folder |
|
54
|
+
| select_page_height | MDE_SELECT_PAGE_HEIGHT | | `12` | Menu page height (maximum) |
|
55
|
+
| user_must_approve | MDE_USER_MUST_APPROVE | `--user-must-approve` | True | Pause to approve execution |
|
56
|
+
|
57
|
+
- Configuration options:
|
58
|
+
|
59
|
+
| YAML Name | Environment Variable | Default |
|
60
|
+
| :--- | :--- | :--- |
|
61
|
+
| block_name_excluded_match | MDE_BLOCK_NAME_EXCLUDED_MATCH | `^\(.+\)$` |
|
62
|
+
| block_name_match | MDE_BLOCK_NAME_MATCH | `:(?<title>\S+)( \|$)` |
|
63
|
+
| block_required_scan | MDE_BLOCK_REQUIRED_SCAN | `\+\S+` |
|
64
|
+
| fenced_start_and_end_match | MDE_FENCED_START_AND_END_MATCH | ``^`{3,}`` |
|
65
|
+
| fenced_start_ex_match | MDE_FENCED_START_EX_MATCH | ``^`{3,}(?<shell>[^`\s]*) *(?<name>.*)$`` |
|
66
|
+
| heading1_match | MDE_HEADING1_MATCH | `^# *(?<name>[^#]*?) *$` |
|
67
|
+
| heading2_match | MDE_HEADING2_MATCH | `^## *(?<name>[^#]*?) *$` |
|
68
|
+
| heading3_match | MDE_HEADING3_MATCH | `^### *(?<name>.+?) *$` |
|
69
|
+
| md_filename_glob | MDE_MD_FILENAME_GLOB | `*.[Mm][Dd]` |
|
70
|
+
| md_filename_match | MDE_MD_FILENAME_MATCH | `.+\\.md` |
|
71
|
+
|
72
|
+
Most options can be configured in multiple ways. In order of use (earliest superceded by last):
|
73
|
+
1. environment variables
|
74
|
+
2. the configuration file `.mde.yml` in the current folder
|
75
|
+
3. command line arguments
|
76
|
+
|
77
|
+
#### Representing boolean values
|
78
|
+
|
79
|
+
Boolean values for options are specified as strings and interpreted as:
|
80
|
+
| Value | Boolean |
|
81
|
+
| :---: | :---: |
|
82
|
+
| *empty string* | False |
|
83
|
+
| `0` | False |
|
84
|
+
| `1` | True |
|
85
|
+
| *anything else* | True |
|
86
|
+
|
87
|
+
E.g. `opt1=1` will set option `opt1` to True.
|
88
|
+
|
89
|
+
Boolean options configured with environment variables:
|
90
|
+
- Set to `1` or non-empty value to save executed scripts; empty or `0` to disable saving.
|
91
|
+
e.g. `export MDE_SAVE_EXECUTED_SCRIPT=1`
|
92
|
+
e.g. `export MDE_SAVE_EXECUTED_SCRIPT=`
|
93
|
+
- Specify variable on command line.
|
94
|
+
e.g. `MDE_SAVE_EXECUTED_SCRIPT=1 mde`
|
95
|
+
|
96
|
+
## [0.2.2] - 2022-03-17
|
97
|
+
|
98
|
+
- Update documentation.
|
99
|
+
|
100
|
+
## [0.2.1] - 2022-03-12
|
101
|
+
|
102
|
+
- Accept file or folder as first optional positional argument.
|
103
|
+
- Hide blocks with parentheses in the name, like "(name)". This is useful for blocks that are to be required and not selected to execute alone.
|
2
104
|
|
3
105
|
## [0.2.0] - 2022-03-12
|
4
106
|
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
markdown_exec (0.
|
4
|
+
markdown_exec (0.2.4)
|
5
5
|
open3 (~> 0.1.1)
|
6
6
|
optparse (~> 0.1.1)
|
7
7
|
tty-prompt (~> 0.23.1)
|
@@ -34,6 +34,10 @@ GEM
|
|
34
34
|
unicode-display_width (>= 1.4.0, < 3.0)
|
35
35
|
rubocop-ast (1.16.0)
|
36
36
|
parser (>= 3.1.1.0)
|
37
|
+
rubocop-minitest (0.18.0)
|
38
|
+
rubocop (>= 0.90, < 2.0)
|
39
|
+
rubocop-rake (0.6.0)
|
40
|
+
rubocop (~> 1.0)
|
37
41
|
ruby-progressbar (1.11.0)
|
38
42
|
tty-color (0.6.0)
|
39
43
|
tty-cursor (0.7.1)
|
@@ -57,6 +61,8 @@ DEPENDENCIES
|
|
57
61
|
minitest (~> 5.0)
|
58
62
|
rake (~> 13.0)
|
59
63
|
rubocop (~> 1.21)
|
64
|
+
rubocop-minitest
|
65
|
+
rubocop-rake
|
60
66
|
|
61
67
|
BUNDLED WITH
|
62
68
|
2.2.32
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# MarkdownExec
|
2
2
|
|
3
|
-
|
3
|
+
Interactively select and execute fenced code blocks in markdown files. Build complex scripts by naming and requiring blocks.
|
4
4
|
|
5
5
|
* Code blocks may be named.
|
6
6
|
|
@@ -10,30 +10,47 @@ This gem allows you to interactively select and run code blocks in markdown file
|
|
10
10
|
|
11
11
|
* The code is presented for approval prior to execution.
|
12
12
|
|
13
|
+
## Screenshots
|
14
|
+
|
15
|
+
### Select a file
|
16
|
+
![Select a file](/assets/select_a_file.png)
|
17
|
+
|
18
|
+
### Select a block
|
19
|
+
![Select a block](/assets/select_a_block.png)
|
20
|
+
|
21
|
+
### Approve code
|
22
|
+
![Approve code](/assets/approve_code.png)
|
23
|
+
|
24
|
+
### Output
|
25
|
+
![Output of execution](/assets/output_of_execution.png)
|
26
|
+
|
27
|
+
### Example blocks
|
28
|
+
![Example blocks](/assets/example_blocks.png)
|
29
|
+
|
13
30
|
## Installation
|
14
31
|
|
15
32
|
Install:
|
16
|
-
|
17
33
|
$ gem install markdown_exec
|
18
34
|
|
19
35
|
## Usage
|
20
36
|
|
21
|
-
`mde --help`
|
37
|
+
### `mde --help`
|
22
38
|
Displays help information.
|
23
39
|
|
24
|
-
`mde`
|
40
|
+
### `mde`
|
25
41
|
Process `README.md` file in the current folder. Displays all the blocks in the file and allows you to select using [up], [down], and [return]. Press [ctrl]-c to abort selection.
|
26
42
|
|
27
|
-
`mde -f my.md`
|
43
|
+
### `mde my.md` or `mde -f my.md`
|
28
44
|
Select a block to execute from `my.md`.
|
29
45
|
|
30
|
-
`mde -p .`
|
46
|
+
### `mde .` or `mde -p .`
|
47
|
+
|
31
48
|
Select a markdown file in the current folder. Select a block to execute from that file.
|
32
49
|
|
33
|
-
`mde --list-blocks`
|
50
|
+
### `mde --list-blocks`
|
34
51
|
List all blocks in the all the markdown documents in the current folder.
|
35
52
|
|
36
|
-
`mde --list-docs`
|
53
|
+
### `mde --list-docs`
|
37
54
|
List all markdown documents in the current folder.
|
38
55
|
|
39
56
|
## Behavior
|
@@ -42,7 +59,6 @@ List all markdown documents in the current folder.
|
|
42
59
|
* If a folder is specified, its files are presented. When a file is selected, its blocks are presented.
|
43
60
|
|
44
61
|
## Configuration
|
45
|
-
|
46
62
|
While starting up, reads the YAML configuration file `.mde.yml` in the current folder if it exists.
|
47
63
|
|
48
64
|
e.g. Use to set the default file for the current folder.
|
@@ -51,49 +67,28 @@ e.g. Use to set the default file for the current folder.
|
|
51
67
|
* `folder: documents` sets the folder to search for default or specified files.
|
52
68
|
|
53
69
|
# Example blocks
|
54
|
-
|
55
|
-
When prompted, select either the `awake` or `asleep` block. The standard output confirms which required were blocks were included. Naming "hidden" blocks with parentheses "(" and ")" is a convention used here to re-inforce the purpose of the named blocks.
|
70
|
+
When prompted, select either the `awake` or `asleep` block.
|
56
71
|
|
57
72
|
``` :(day)
|
58
|
-
|
59
|
-
export MYTIME=early
|
73
|
+
export TIME=early
|
60
74
|
```
|
61
75
|
|
62
76
|
``` :(night)
|
63
|
-
|
64
|
-
export MYTIME=late
|
77
|
+
export TIME=late
|
65
78
|
```
|
66
79
|
|
67
80
|
``` :awake +(day) +(report)
|
68
|
-
# block named "awake", select to see result
|
69
81
|
export ACTIVITY=awake
|
70
82
|
```
|
71
83
|
|
72
84
|
``` :asleep +(night) +(report)
|
73
|
-
# block named "asleep", select to see result
|
74
85
|
export ACTIVITY=asleep
|
75
86
|
```
|
76
87
|
|
77
88
|
``` :(report)
|
78
|
-
|
79
|
-
echo "time: $MYTIME, activity: $ACTIVITY"
|
89
|
+
echo "$TIME -> $ACTIVITY"
|
80
90
|
```
|
81
91
|
|
82
|
-
## Example blocks
|
83
|
-
![Sample blocks](/assets/blocks.png)
|
84
|
-
|
85
|
-
## Selecting a file
|
86
|
-
![Selecting a file](/assets/select_file.png)
|
87
|
-
|
88
|
-
## Selecting a block
|
89
|
-
![Selecting a block](/assets/select.png)
|
90
|
-
|
91
|
-
## Approving code
|
92
|
-
![Approving code](/assets/approve.png)
|
93
|
-
|
94
|
-
## Output
|
95
|
-
![Output of execution](/assets/executed.png)
|
96
|
-
|
97
92
|
# License
|
98
93
|
|
99
94
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
CHANGED
@@ -3,38 +3,50 @@
|
|
3
3
|
require 'bundler/gem_tasks'
|
4
4
|
require 'rake/testtask'
|
5
5
|
|
6
|
-
Rake::TestTask.new(:test) do |
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
Rake::TestTask.new(:test) do |task|
|
7
|
+
task.libs << 'test'
|
8
|
+
task.libs << 'lib'
|
9
|
+
task.test_files = FileList['test/**/*_test.rb']
|
10
10
|
end
|
11
11
|
|
12
12
|
require 'rubocop/rake_task'
|
13
13
|
|
14
|
-
RuboCop::RakeTask.new
|
14
|
+
RuboCop::RakeTask.new do |task|
|
15
|
+
# task.requires << 'rubocop-minitest'
|
16
|
+
end
|
17
|
+
|
18
|
+
desc 'named task because minitest not included in rubocop tests'
|
19
|
+
task :rubocopminitest do
|
20
|
+
`rubocop --require rubocop-minitest`
|
21
|
+
end
|
15
22
|
|
16
23
|
require_relative 'lib/markdown_exec/version'
|
17
24
|
|
18
|
-
task default: %i[test rubocop]
|
25
|
+
task default: %i[test rubocop rubocopminitest]
|
19
26
|
|
20
27
|
# task :default => :build
|
21
28
|
|
29
|
+
desc 'gem build'
|
22
30
|
task :build do
|
23
31
|
system "gem build #{MarkdownExec::GEM_NAME}.gemspec"
|
24
32
|
end
|
25
33
|
|
34
|
+
desc 'gem install'
|
26
35
|
task install: :build do
|
27
36
|
system "gem install #{MarkdownExec::GEM_NAME}-#{MarkdownExec::VERSION}.gem"
|
28
37
|
end
|
29
38
|
|
39
|
+
desc 'gem publish'
|
30
40
|
task publish: :build do
|
31
41
|
system "gem push #{MarkdownExec::GEM_NAME}-#{MarkdownExec::VERSION}.gem"
|
32
42
|
end
|
33
43
|
|
44
|
+
desc 'gem uninstall'
|
34
45
|
task uninstall: :build do
|
35
46
|
system "gem uninstall #{MarkdownExec::GEM_NAME}"
|
36
47
|
end
|
37
48
|
|
49
|
+
desc 'gem build clean'
|
38
50
|
task :clean do
|
39
51
|
system 'rm *.gem'
|
40
52
|
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/fixtures/bash1.md
ADDED
data/fixtures/bash2.md
ADDED
data/fixtures/exec1.md
ADDED
data/fixtures/sample1.md
ADDED
data/fixtures/title1.md
ADDED