markdown_exec 0.1.3 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bf18f8937c1601bf8e6d19698d74c327c16ebfce07868249ebacddf0d7397dad
4
- data.tar.gz: 6b8bb53ad8c9f21aa4c267984ff8ab02154c617a6b3f5de230763dbb81436131
3
+ metadata.gz: 7ec074d1854ef0150cf60852fd39d7db7bc88461f7d9f5ae6547fe009142ffb4
4
+ data.tar.gz: 8d6eb3c7759bf180b996f8a68ec8b52d0e52a230365b163f06528e9c11627e42
5
5
  SHA512:
6
- metadata.gz: 15a0d5aba4cc5b88b4f586bb59313f61c9d461564252f8653c71696f1f6d2e3ea32c72c3ca8a9b70e5ebe74c398ddba97758b460e0770f7cd2b3da7ae15be4ba
7
- data.tar.gz: adf64d06a15ef0e2259557ac79e5ec4ead8a4dfa36ed15f706f19a9169a1006388fcdd4ee19ec790f3f6b0f350044b29b7cf002fb82a0ce019f9b1062a948603
6
+ metadata.gz: '095584193734695c29729060ca4ccd424088ca59cdd8bf539dda5a6b914d7fd71d373304f071e46b49072bf01b09ae2a1f0cf86bf314f3d79ace9acd166a3531'
7
+ data.tar.gz: c8e55fa064fe9bc8c170c9431dd1a5dc9fd3f20f1fe42925c00c4f2ed5113d597f457ecdba225cf4533563cd0c3f14f35ebc1ad096e8a89f8ec654a5cd87cd8c
data/.rubocop.yml CHANGED
@@ -1,4 +1,9 @@
1
+ require:
2
+ - rubocop-minitest
3
+ - rubocop-rake
4
+
1
5
  AllCops:
6
+ NewCops: enable
2
7
  TargetRubyVersion: 2.6
3
8
 
4
9
  Metrics/AbcSize:
data/CHANGELOG.md CHANGED
@@ -1,5 +1,120 @@
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
+
109
+ ## [0.2.1] - 2022-03-12
110
+
111
+ - Accept file or folder as first optional positional argument.
112
+ - 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.
113
+
114
+ ## [0.2.0] - 2022-03-12
115
+
116
+ - Improve processing of file and path sepcs.
117
+
3
118
  ## [0.1.0] - 2022-03-06
4
119
 
5
120
  - Initial release
data/Gemfile CHANGED
@@ -10,3 +10,5 @@ gem 'rake', '~> 13.0'
10
10
  gem 'minitest', '~> 5.0'
11
11
 
12
12
  gem 'rubocop', '~> 1.21'
13
+ gem 'rubocop-minitest', require: false
14
+ gem 'rubocop-rake', require: false
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- markdown_exec (0.1.1)
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,43 +1,98 @@
1
1
  # MarkdownExec
2
2
 
3
- This gem allows you to interactively select and run code blocks in markdown files.
3
+ Interactively select and execute fenced code blocks in markdown files. Build complex scripts by naming and requiring blocks.
4
4
 
5
- * Code blocks can be named.
5
+ * Code blocks may be named.
6
6
 
7
7
  * Named blocks can be required by other blocks.
8
8
 
9
- * The selected code block, and all required blocks, are collected in the order they appear in the markdown file.
9
+ * The user-selected code block, and all required blocks, are arranged in the order they appear in the markdown file.
10
+
11
+ * The code is presented for approval prior to execution.
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)
10
29
 
11
30
  ## Installation
12
31
 
13
32
  Install:
14
-
15
33
  $ gem install markdown_exec
16
34
 
17
35
  ## Usage
18
36
 
19
- `mde --help`
37
+ ### `mde --help`
20
38
  Displays help information.
21
39
 
22
- `mde`
23
- Process `README.md` file in the current directory. Displays all the blocks in the file and allows you to select using [up], [down], and [return]. Press [ctrl]-c to abort selection.
40
+ ### `mde`
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.
42
+
43
+ ### `mde my.md` or `mde -f my.md`
44
+ Select a block to execute from `my.md`.
45
+
46
+ ### `mde .` or `mde -p .`
47
+
48
+ Select a markdown file in the current folder. Select a block to execute from that file.
49
+
50
+ ### `mde --list-blocks`
51
+ List all blocks in the all the markdown documents in the current folder.
52
+
53
+ ### `mde --list-docs`
54
+ List all markdown documents in the current folder.
55
+
56
+ ## Behavior
57
+ * If no file and no folder are specified, blocks within `./README.md` are presented.
58
+ * If a file is specified, its blocks are presented.
59
+ * If a folder is specified, its files are presented. When a file is selected, its blocks are presented.
60
+
61
+ ## Configuration
62
+ While starting up, reads the YAML configuration file `.mde.yml` in the current folder if it exists.
63
+
64
+ e.g. Use to set the default file for the current folder.
65
+
66
+ * `filename: CHANGELOG.md` sets the file to open.
67
+ * `folder: documents` sets the folder to search for default or specified files.
68
+
69
+ # Example blocks
70
+ When prompted, select either the `awake` or `asleep` block.
71
+
72
+ ``` :(day)
73
+ export TIME=early
74
+ ```
24
75
 
25
- `mde -f my.md`
26
- Process `my.md` file in the current directory.
76
+ ``` :(night)
77
+ export TIME=late
78
+ ```
27
79
 
28
- `mde -p child`
29
- Process markdown files in the `child` directory.
80
+ ``` :awake +(day) +(report)
81
+ export ACTIVITY=awake
82
+ ```
30
83
 
31
- `mde --list-blocks`
32
- List all blocks in the selected files.
84
+ ``` :asleep +(night) +(report)
85
+ export ACTIVITY=asleep
86
+ ```
33
87
 
34
- `mde --list-docs`
35
- List all markdown documents in the selected folder.
88
+ ``` :(report)
89
+ echo "$TIME -> $ACTIVITY"
90
+ ```
36
91
 
37
- ## License
92
+ # License
38
93
 
39
94
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
95
 
41
- ## Code of Conduct
96
+ # Code of Conduct
42
97
 
43
98
  Everyone interacting in the MarkdownExec project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/markdown_exec/blob/master/CODE_OF_CONDUCT.md).
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 |t|
7
- t.libs << 'test'
8
- t.libs << 'lib'
9
- t.test_files = FileList['test/**/*_test.rb']
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
@@ -0,0 +1,12 @@
1
+ ``` :one
2
+ a
3
+ ```
4
+ ```bash :two +one
5
+ b
6
+ ```
7
+ ```bash :three +two +one
8
+ c
9
+ ```
10
+ ```bash :four +three
11
+ d
12
+ ```
data/fixtures/bash2.md ADDED
@@ -0,0 +1,15 @@
1
+ ``` :one
2
+ a
3
+ ```
4
+ ``` :two +one
5
+ b
6
+ ```
7
+ ``` :three +two
8
+ c
9
+ ```
10
+ ``` :four
11
+ d
12
+ ```
13
+ ``` :five +four +one
14
+ e
15
+ ```
@@ -0,0 +1,6 @@
1
+ ``` :one
2
+ a
3
+ ```
4
+ ```expect
5
+ b
6
+ ```
@@ -0,0 +1,9 @@
1
+ ``` :one
2
+ a
3
+ ```
4
+ ``` :(two)
5
+ b
6
+ ```
7
+ ``` :three
8
+ c
9
+ ```
data/fixtures/exec1.md ADDED
@@ -0,0 +1,8 @@
1
+ ```bash ls
2
+ ls
3
+ ```
4
+
5
+ ```bash two-three
6
+ echo "TWO"
7
+ echo "THREE"
8
+ ```
@@ -0,0 +1,19 @@
1
+ ``` :one
2
+ a
3
+ ```
4
+ # h1
5
+ ``` :two
6
+ b
7
+ ```
8
+ ## h2
9
+ ``` :three
10
+ c
11
+ ```
12
+ ### h3
13
+ ``` :four
14
+ d
15
+ ```
16
+ ### h4
17
+ ``` :five
18
+ e
19
+ ```
@@ -0,0 +1,9 @@
1
+ #
2
+ ##
3
+ ``` one
4
+ a
5
+ ```
6
+
7
+ ```bash two
8
+ b
9
+ ```
@@ -0,0 +1,6 @@
1
+ ```
2
+ no name
3
+ ```
4
+ ``` :name1
5
+ with name
6
+ ```
@@ -4,5 +4,5 @@ module MarkdownExec
4
4
  APP_NAME = 'MDE'
5
5
  APP_DESC = 'Markdown block executor'
6
6
  GEM_NAME = 'markdown_exec'
7
- VERSION = '0.1.3'
7
+ VERSION = '0.2.3'
8
8
  end