markdown_exec 0.2.1 → 0.2.3
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/.rubocop.yml +5 -0
- data/CHANGELOG.md +106 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +7 -1
- data/README.md +25 -27
- 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 +410 -258
- 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: 7ec074d1854ef0150cf60852fd39d7db7bc88461f7d9f5ae6547fe009142ffb4
|
4
|
+
data.tar.gz: 8d6eb3c7759bf180b996f8a68ec8b52d0e52a230365b163f06528e9c11627e42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '095584193734695c29729060ca4ccd424088ca59cdd8bf539dda5a6b914d7fd71d373304f071e46b49072bf01b09ae2a1f0cf86bf314f3d79ace9acd166a3531'
|
7
|
+
data.tar.gz: c8e55fa064fe9bc8c170c9431dd1a5dc9fd3f20f1fe42925c00c4f2ed5113d597f457ecdba225cf4533563cd0c3f14f35ebc1ad096e8a89f8ec654a5cd87cd8c
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,111 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## [ToDo]
|
4
|
+
|
5
|
+
- pipe stdin to script
|
6
|
+
- yes/no/write/clipboard/record/edit/history
|
7
|
+
- add confirm block to generated file
|
8
|
+
- present timestamp, result of last exec for each command
|
9
|
+
- user settings
|
10
|
+
- hidden w , w/o () in names
|
11
|
+
- exit in menus
|
12
|
+
- fix regexp in pathnames
|
13
|
+
- tab completion from md file
|
14
|
+
- read file once to allow for tempdoc stream
|
15
|
+
- include md or blocks file
|
16
|
+
|
17
|
+
- tree display
|
18
|
+
|
19
|
+
- mde options in md file or included file
|
20
|
+
|
21
|
+
- include blocks from local md file
|
22
|
+
|
23
|
+
- save outputs, errors
|
24
|
+
|
25
|
+
- chmod a+x logged script
|
26
|
+
|
27
|
+
- exec most recent logged scripts
|
28
|
+
|
29
|
+
- cmd to list last n
|
30
|
+
- cmd to repeat last
|
31
|
+
|
1
32
|
## [Unreleased]
|
2
33
|
|
34
|
+
## [0.2.3] - 2022-03
|
35
|
+
|
36
|
+
### Added
|
37
|
+
|
38
|
+
- `rubocop` checks.
|
39
|
+
- Added optional command-line positional arguments:
|
40
|
+
1. document file
|
41
|
+
2. block name
|
42
|
+
|
43
|
+
e.g. `mde doc1 block1` will execute the block named `block1` in file `doc1`.
|
44
|
+
|
45
|
+
### Changed
|
46
|
+
|
47
|
+
- Naming saved script files: The file name contains the time stamp, document name, and block name.
|
48
|
+
|
49
|
+
- Renamed folder with fixtures.
|
50
|
+
|
51
|
+
- Command options:
|
52
|
+
|
53
|
+
| YAML Name | Environment Variable | Option Name | Default | Purpose |
|
54
|
+
| :--- | :--- | :--- | :--- | :--- |
|
55
|
+
| debug | MDE_DEBUG | `--debug` | False | Output debugging information (verbose) |
|
56
|
+
| filename | MDE_FILENAME | `--filename` | `README.md`* | File name of document |
|
57
|
+
| output_execution_summary | MDE_OUTPUT_STDOUT_SUMMARY | `--output-execution-summary` | False | Display summary for execution |
|
58
|
+
| output_script | MDE_OUTPUT_SCRIPT | `--output-script` | False | Display script |
|
59
|
+
| output_stdout | MDE_OUTPUT_EXECUTION | `--output-stdout` | True | Display standard output from execution |
|
60
|
+
| path | MDE_PATH | `--path` | `.` | Path to document(s) |
|
61
|
+
| save_executed_script | MDE_SAVE_EXECUTED_SCRIPT | `--save-executed-script` | False | Save executed script |
|
62
|
+
| saved_script_folder | MDE_SAVED_SCRIPT_FOLDER | `--saved-script-folder` | `logs` | Saved script folder |
|
63
|
+
| select_page_height | MDE_SELECT_PAGE_HEIGHT | | `12` | Menu page height (maximum) |
|
64
|
+
| user_must_approve | MDE_USER_MUST_APPROVE | `--user-must-approve` | True | Pause to approve execution |
|
65
|
+
|
66
|
+
- Configuration options:
|
67
|
+
|
68
|
+
| YAML Name | Environment Variable | Default |
|
69
|
+
| :--- | :--- | :--- |
|
70
|
+
| block_name_excluded_match | MDE_BLOCK_NAME_EXCLUDED_MATCH | `^\(.+\)$` |
|
71
|
+
| block_name_match | MDE_BLOCK_NAME_MATCH | `:(?<title>\S+)( \|$)` |
|
72
|
+
| block_required_scan | MDE_BLOCK_REQUIRED_SCAN | `\+\S+` |
|
73
|
+
| fenced_start_and_end_match | MDE_FENCED_START_AND_END_MATCH | `^\`{3,}` |
|
74
|
+
| fenced_start_ex_match | MDE_FENCED_START_EX_MATCH | `^\`{3,}(?<shell>[^\`\s]*) *(?<name>.*)$` |
|
75
|
+
| heading1_match | MDE_HEADING1_MATCH | `^# *(?<name>[^#]*?) *$` |
|
76
|
+
| heading2_match | MDE_HEADING2_MATCH | `^## *(?<name>[^#]*?) *$` |
|
77
|
+
| heading3_match | MDE_HEADING3_MATCH | `^### *(?<name>.+?) *$` |
|
78
|
+
| md_filename_glob | MDE_MD_FILENAME_GLOB | `*.[Mm][Dd]` |
|
79
|
+
| md_filename_match | MDE_MD_FILENAME_MATCH | `.+\\.md` |
|
80
|
+
|
81
|
+
Most options can be configured in multiple ways. In order of use (earliest superceded by last):
|
82
|
+
1. environment variables
|
83
|
+
2. the configuration file `.mde.yml` in the current folder
|
84
|
+
3. command line arguments
|
85
|
+
|
86
|
+
#### Representing boolean values
|
87
|
+
|
88
|
+
Boolean values for options are specified as strings and interpreted as:
|
89
|
+
| Value | Boolean |
|
90
|
+
| :---: | :---: |
|
91
|
+
| *empty string* | False |
|
92
|
+
| `0` | False |
|
93
|
+
| `1` | True |
|
94
|
+
| *anything else* | True |
|
95
|
+
|
96
|
+
E.g. `opt1=1` will set option `opt1` to True.
|
97
|
+
|
98
|
+
Boolean options configured with environment variables:
|
99
|
+
- Set to `1` or non-empty value to save executed scripts; empty or `0` to disable saving.
|
100
|
+
e.g. `export MDE_SAVE_EXECUTED_SCRIPT=1`
|
101
|
+
e.g. `export MDE_SAVE_EXECUTED_SCRIPT=`
|
102
|
+
- Specify variable on command line.
|
103
|
+
e.g. `MDE_SAVE_EXECUTED_SCRIPT=1 mde`
|
104
|
+
|
105
|
+
## [0.2.2] - 2022-03-17
|
106
|
+
|
107
|
+
- Update documentation.
|
108
|
+
|
3
109
|
## [0.2.1] - 2022-03-12
|
4
110
|
|
5
111
|
- Accept file or folder as first optional positional argument.
|
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.3)
|
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,32 +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
|
+

|
17
|
+
|
18
|
+
### Select a block
|
19
|
+

|
20
|
+
|
21
|
+
### Approve code
|
22
|
+

|
23
|
+
|
24
|
+
### Output
|
25
|
+

|
26
|
+
|
27
|
+
### Example blocks
|
28
|
+

|
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`
|
28
|
-
`mde my.md`
|
43
|
+
### `mde my.md` or `mde -f my.md`
|
29
44
|
Select a block to execute from `my.md`.
|
30
45
|
|
31
|
-
`mde -p .`
|
32
|
-
|
46
|
+
### `mde .` or `mde -p .`
|
47
|
+
|
33
48
|
Select a markdown file in the current folder. Select a block to execute from that file.
|
34
49
|
|
35
|
-
`mde --list-blocks`
|
50
|
+
### `mde --list-blocks`
|
36
51
|
List all blocks in the all the markdown documents in the current folder.
|
37
52
|
|
38
|
-
`mde --list-docs`
|
53
|
+
### `mde --list-docs`
|
39
54
|
List all markdown documents in the current folder.
|
40
55
|
|
41
56
|
## Behavior
|
@@ -44,7 +59,6 @@ List all markdown documents in the current folder.
|
|
44
59
|
* If a folder is specified, its files are presented. When a file is selected, its blocks are presented.
|
45
60
|
|
46
61
|
## Configuration
|
47
|
-
|
48
62
|
While starting up, reads the YAML configuration file `.mde.yml` in the current folder if it exists.
|
49
63
|
|
50
64
|
e.g. Use to set the default file for the current folder.
|
@@ -53,7 +67,6 @@ e.g. Use to set the default file for the current folder.
|
|
53
67
|
* `folder: documents` sets the folder to search for default or specified files.
|
54
68
|
|
55
69
|
# Example blocks
|
56
|
-
|
57
70
|
When prompted, select either the `awake` or `asleep` block.
|
58
71
|
|
59
72
|
``` :(day)
|
@@ -76,21 +89,6 @@ export ACTIVITY=asleep
|
|
76
89
|
echo "$TIME -> $ACTIVITY"
|
77
90
|
```
|
78
91
|
|
79
|
-
## Example blocks
|
80
|
-

|
81
|
-
|
82
|
-
## Selecting a file
|
83
|
-

|
84
|
-
|
85
|
-
## Selecting a block
|
86
|
-

|
87
|
-
|
88
|
-
## Approving code
|
89
|
-

|
90
|
-
|
91
|
-
## Output
|
92
|
-

|
93
|
-
|
94
92
|
# License
|
95
93
|
|
96
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