markdown_exec 1.0.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.reek +24 -0
- data/CHANGELOG.md +75 -11
- data/Gemfile +7 -5
- data/Gemfile.lock +19 -1
- data/README.md +25 -8
- data/Rakefile +56 -2
- data/bin/tab_completion.sh +131 -3
- data/bin/tab_completion.sh.erb +85 -0
- data/lib/colorize.rb +64 -0
- data/lib/env.rb +37 -0
- data/lib/markdown_exec/version.rb +3 -2
- data/lib/markdown_exec.rb +915 -368
- data/lib/shared.rb +19 -0
- data/lib/tap.rb +36 -0
- metadata +31 -11
- data/fixtures/bash1.md +0 -12
- data/fixtures/bash2.md +0 -15
- data/fixtures/exclude1.md +0 -6
- data/fixtures/exclude2.md +0 -12
- data/fixtures/exec1.md +0 -8
- data/fixtures/heading1.md +0 -19
- data/fixtures/sample1.md +0 -9
- data/fixtures/title1.md +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 160eb660362db62302a05b8b46398c6d85357c917ee55eeb89a8ce0f739eec8a
|
4
|
+
data.tar.gz: 706e575c290ec56d34ad58f06ca9e30127b2c0bdacf431a4c9e3f69bc30e80dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f540464a21a3ca2b654d89b3bc32f2172a3e610066bc64b9eae1bc29d99b8006ed3581998a50ae2327052c944656584375df55e64ffeeb77864ae05e45325e1c
|
7
|
+
data.tar.gz: a22c5ff757a2b5173725786bdbc399cae29f63eda891a0741149286391cb413abbcccd3799bd15ec769230ed44245b49664d434c77c12610bc2cfc138a9d3ddb
|
data/.reek
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
---
|
2
|
+
detectors:
|
3
|
+
DataClump:
|
4
|
+
enabled: false
|
5
|
+
NilCheck:
|
6
|
+
enabled: false
|
7
|
+
TooManyStatements:
|
8
|
+
enabled: false
|
9
|
+
UtilityFunction:
|
10
|
+
public_methods_only: true
|
11
|
+
ControlParameter:
|
12
|
+
enabled: true
|
13
|
+
DuplicateMethodCall:
|
14
|
+
enabled: true
|
15
|
+
FeatureEnvy:
|
16
|
+
enabled: false # too strict
|
17
|
+
InstanceVariableAssumption:
|
18
|
+
enabled: true
|
19
|
+
IrresponsibleModule:
|
20
|
+
enabled: true
|
21
|
+
LongParameterList:
|
22
|
+
enabled: true
|
23
|
+
LongYieldList:
|
24
|
+
enabled: true
|
data/CHANGELOG.md
CHANGED
@@ -1,29 +1,93 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
3
|
## [ToDo]
|
4
|
+
`reek lib/markdown_exec.rb --config .reek`
|
4
5
|
|
5
|
-
- pipe stdin to script
|
6
|
-
- present timestamp, result of last exec for each command
|
7
6
|
- user settings
|
8
7
|
- hidden w , w/o () in names
|
9
8
|
- fix regexp in pathnames
|
10
|
-
|
11
|
-
- read file once to allow for tempdoc stream
|
12
|
-
- include md or blocks file
|
9
|
+
|
10
|
+
- [ ] read file once to allow for tempdoc stream
|
13
11
|
|
14
12
|
- tree display
|
15
13
|
|
16
|
-
- mde options in md file or included file
|
14
|
+
- [ ] mde options, user prompt, in md file or included file
|
15
|
+
|
16
|
+
- [ ] include blocks from local md file
|
17
|
+
|
18
|
+
- execute? yes/no/save/clipboard + record/edit/history
|
19
|
+
|
20
|
+
- [ ] list, view saved output
|
21
|
+
|
22
|
+
- completion
|
23
|
+
- [ ] include blocks in md file
|
24
|
+
|
25
|
+
- [ ] ruby gem data model
|
26
|
+
|
27
|
+
- [ ] extract yaml block into stdout
|
28
|
+
- [ ] extract json block into stdout
|
17
29
|
|
18
|
-
-
|
30
|
+
- [ ] import yaml, json data into environment
|
19
31
|
|
20
|
-
-
|
32
|
+
- [ ] yq filter with imported or named yaml, json data
|
21
33
|
|
22
|
-
-
|
34
|
+
- [ ] yaml dump of options w/ detail
|
35
|
+
|
36
|
+
- [ ] re-exec last script v re-run named block in last script
|
37
|
+
- [ ] repeat to reload last doc and block
|
38
|
+
- [ ] option to log blended, timeline; stdin, stdout, stderr; labels: prefix and blocks
|
39
|
+
- [ ] ren logged_stdout_filename_prefix to saved_stdout_filename_prefix
|
40
|
+
- [ ] ignore '#' in fenced code blocks
|
41
|
+
|
42
|
+
## [1.2.0] - 2022-06-11
|
43
|
+
|
44
|
+
### Added
|
45
|
+
|
46
|
+
- Options
|
47
|
+
- Display document name in block selection menu
|
48
|
+
- Display headings (levels 1,2,3) in block selection menu
|
49
|
+
- Trap Ctrl-C (SIGTERM) while script is executing.
|
50
|
+
Completes MDE processes such as saving output and reporting results.
|
51
|
+
|
52
|
+
### Changed
|
23
53
|
|
24
|
-
-
|
54
|
+
- Refactoring
|
55
|
+
|
56
|
+
## [1.1.1] - 2022-05-25
|
57
|
+
|
58
|
+
### Added
|
59
|
+
|
60
|
+
- Post-install instructions to add tab completions permanently to the shell.
|
61
|
+
|
62
|
+
### Changed
|
63
|
+
|
64
|
+
- Improve handling of threads ending while executing scripts.
|
65
|
+
|
66
|
+
## [1.1.0] - 2022-05-21
|
67
|
+
|
68
|
+
### Added
|
69
|
+
|
70
|
+
- Display administrative output (command, save files) for executed blocks.
|
71
|
+
- Select base, administrative output as hierarchical output (MDE_DISPLAY_LEVEL).
|
72
|
+
- The user may select Exit, the first option, to quit the program.
|
73
|
+
- The block-selection menu is re-displayed after an approved script is exectued.
|
74
|
+
- Pause for and pass through standard input in scripts executed by the tool.
|
75
|
+
- Options
|
76
|
+
- chmod for saved scripts
|
77
|
+
- shebang for saved scripts
|
78
|
+
- shell for executed and saved scripts
|
79
|
+
|
80
|
+
### Changed
|
25
81
|
|
26
|
-
-
|
82
|
+
- Exit option is at top of each menu.
|
83
|
+
- Single-stage tab completion, default
|
84
|
+
- Presents matching options when current word starts with `-`
|
85
|
+
- Presents directories and files otherwise.
|
86
|
+
- Two-stage tab completion for option arguments.
|
87
|
+
- When prior word is an option and current word is empty
|
88
|
+
- Presents option type on first tab, eg `.BOOL.` for a boolean option.
|
89
|
+
- Presents option default value on second tab, eg `0` for false.
|
90
|
+
- Write STDOUT, STDERR, STDIN in sections to saved output file.
|
27
91
|
|
28
92
|
## [1.0.0] - 2022-04-26
|
29
93
|
|
data/Gemfile
CHANGED
@@ -2,13 +2,15 @@
|
|
2
2
|
|
3
3
|
source 'https://rubygems.org'
|
4
4
|
|
5
|
-
# Specify your gem's dependencies in markdown_exec.gemspec
|
6
5
|
gemspec
|
7
|
-
|
8
|
-
gem '
|
9
|
-
|
6
|
+
gem 'clipboard'
|
7
|
+
gem 'erb'
|
10
8
|
gem 'minitest', '~> 5.0'
|
11
|
-
|
9
|
+
gem 'rake', '~> 13.0'
|
10
|
+
gem 'reek'
|
12
11
|
gem 'rubocop', '~> 1.21'
|
13
12
|
gem 'rubocop-minitest', require: false
|
14
13
|
gem 'rubocop-rake', require: false
|
14
|
+
gem 'shellwords'
|
15
|
+
gem 'uri'
|
16
|
+
gem 'yaml'
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
markdown_exec (1.
|
4
|
+
markdown_exec (1.2.0)
|
5
|
+
clipboard (~> 1.3.6)
|
5
6
|
open3 (~> 0.1.1)
|
6
7
|
optparse (~> 0.1.1)
|
7
8
|
tty-prompt (~> 0.23.1)
|
@@ -11,6 +12,11 @@ GEM
|
|
11
12
|
remote: https://rubygems.org/
|
12
13
|
specs:
|
13
14
|
ast (2.4.2)
|
15
|
+
cgi (0.3.2)
|
16
|
+
clipboard (1.3.6)
|
17
|
+
erb (2.2.3)
|
18
|
+
cgi
|
19
|
+
kwalify (0.7.2)
|
14
20
|
minitest (5.15.0)
|
15
21
|
open3 (0.1.1)
|
16
22
|
optparse (0.1.1)
|
@@ -21,6 +27,10 @@ GEM
|
|
21
27
|
tty-color (~> 0.5)
|
22
28
|
rainbow (3.1.1)
|
23
29
|
rake (13.0.6)
|
30
|
+
reek (6.1.1)
|
31
|
+
kwalify (~> 0.7.0)
|
32
|
+
parser (~> 3.1.0)
|
33
|
+
rainbow (>= 2.0, < 4.0)
|
24
34
|
regexp_parser (2.2.1)
|
25
35
|
rexml (3.2.5)
|
26
36
|
rubocop (1.26.0)
|
@@ -39,6 +49,7 @@ GEM
|
|
39
49
|
rubocop-rake (0.6.0)
|
40
50
|
rubocop (~> 1.0)
|
41
51
|
ruby-progressbar (1.11.0)
|
52
|
+
shellwords (0.1.0)
|
42
53
|
tty-color (0.6.0)
|
43
54
|
tty-cursor (0.7.1)
|
44
55
|
tty-prompt (0.23.1)
|
@@ -50,6 +61,7 @@ GEM
|
|
50
61
|
wisper (~> 2.0)
|
51
62
|
tty-screen (0.8.1)
|
52
63
|
unicode-display_width (2.1.0)
|
64
|
+
uri (0.11.0)
|
53
65
|
wisper (2.0.1)
|
54
66
|
yaml (0.2.0)
|
55
67
|
|
@@ -57,12 +69,18 @@ PLATFORMS
|
|
57
69
|
arm64-darwin-21
|
58
70
|
|
59
71
|
DEPENDENCIES
|
72
|
+
clipboard
|
73
|
+
erb
|
60
74
|
markdown_exec!
|
61
75
|
minitest (~> 5.0)
|
62
76
|
rake (~> 13.0)
|
77
|
+
reek
|
63
78
|
rubocop (~> 1.21)
|
64
79
|
rubocop-minitest
|
65
80
|
rubocop-rake
|
81
|
+
shellwords
|
82
|
+
uri
|
83
|
+
yaml
|
66
84
|
|
67
85
|
BUNDLED WITH
|
68
86
|
2.2.32
|
data/README.md
CHANGED
@@ -150,21 +150,34 @@ Boolean options configured with environment variables:
|
|
150
150
|
|
151
151
|
### Install tab completion
|
152
152
|
|
153
|
-
Append a command to load the completion script to your shell configuration file
|
153
|
+
Append a command to load the completion script to your shell configuration file. `mde` must be executable for the command to be composed correctly.
|
154
154
|
|
155
155
|
```bash :()
|
156
156
|
echo "source $(mde --pwd)/bin/tab_completion.sh" >> ~/.bash_profile
|
157
157
|
```
|
158
158
|
|
159
|
+
### Behavior
|
160
|
+
|
161
|
+
Press tab for completions appropriate to the current input.
|
162
|
+
`mde <...> <prior word> <current word>`
|
163
|
+
|
164
|
+
Completions are calculated based on the current word and the prior word.
|
165
|
+
1. If the current word starts with `-`, present matching options, eg `--version` for the current word `--v`.
|
166
|
+
2. Else, if the current word is empty and the prior word is an option that takes an argument, present the type of the argument, eg `.BOOL.` for the option `--user-must-approve`.
|
167
|
+
3. Else, if the current word is the type of argument, from the rule above, present the default value for the option. e.g. `1` for the type `.BOOL.` for the option `--user-must-approve`.
|
168
|
+
4. Else, if the current word is non-empty, list matching files and folders.
|
169
|
+
|
159
170
|
### Example Completions
|
160
171
|
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
172
|
+
In the table below, tab is indicated by `!`
|
173
|
+
| Input | Completions |
|
174
|
+
| :---: | :---: |
|
175
|
+
| `mde !` | local files and folders |
|
176
|
+
| `mde -!` | all options |
|
177
|
+
| `mde --!` | all options |
|
178
|
+
| `mde --v!` | `mde --version` |
|
179
|
+
| `mde --user-must-approve !` | `mde --user-must-approve .BOOL.`|
|
180
|
+
| `mde --user-must-approve .BOOL.!` | `mde --user-must-approve 1` |
|
168
181
|
|
169
182
|
## Example Blocks
|
170
183
|
|
@@ -190,6 +203,10 @@ export ACTIVITY=asleep
|
|
190
203
|
echo "$TIME -> $ACTIVITY"
|
191
204
|
```
|
192
205
|
|
206
|
+
``` :sleep
|
207
|
+
sleep 10
|
208
|
+
```
|
209
|
+
|
193
210
|
# License
|
194
211
|
|
195
212
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
require 'bundler/gem_tasks'
|
4
4
|
require 'rake/testtask'
|
5
|
+
require 'erb'
|
6
|
+
require 'yaml'
|
5
7
|
|
6
8
|
Rake::TestTask.new(:test) do |task|
|
7
9
|
task.libs << 'test'
|
@@ -11,8 +13,13 @@ end
|
|
11
13
|
|
12
14
|
require 'rubocop/rake_task'
|
13
15
|
|
16
|
+
require_relative 'lib/shared'
|
17
|
+
require_relative 'lib/tap'
|
18
|
+
|
19
|
+
include Tap # rubocop:disable Style/MixinUsage
|
20
|
+
|
14
21
|
RuboCop::RakeTask.new do |task|
|
15
|
-
|
22
|
+
task.requires << 'rubocop-minitest'
|
16
23
|
end
|
17
24
|
|
18
25
|
desc 'named task because minitest not included in rubocop tests'
|
@@ -22,12 +29,13 @@ end
|
|
22
29
|
|
23
30
|
require_relative 'lib/markdown_exec/version'
|
24
31
|
|
25
|
-
task default: %i[test rubocop rubocopminitest]
|
32
|
+
task default: %i[test reek rubocop rubocopminitest]
|
26
33
|
|
27
34
|
# task :default => :build
|
28
35
|
|
29
36
|
desc 'gem build'
|
30
37
|
task :build do
|
38
|
+
Rake::Task['update_tab_completion'].execute
|
31
39
|
system "gem build #{MarkdownExec::GEM_NAME}.gemspec"
|
32
40
|
end
|
33
41
|
|
@@ -50,3 +58,49 @@ desc 'gem build clean'
|
|
50
58
|
task :clean do
|
51
59
|
system 'rm *.gem'
|
52
60
|
end
|
61
|
+
|
62
|
+
desc 'reek'
|
63
|
+
task :reek do
|
64
|
+
`reek --config .reek .`
|
65
|
+
end
|
66
|
+
|
67
|
+
private
|
68
|
+
|
69
|
+
BF = 'bin'
|
70
|
+
|
71
|
+
# format for use in array in bash script
|
72
|
+
# `opts=<%= mde_tab_completions %>`
|
73
|
+
#
|
74
|
+
def words_list(words)
|
75
|
+
words.map do |word|
|
76
|
+
%("#{word}")
|
77
|
+
end.join ' '
|
78
|
+
end
|
79
|
+
|
80
|
+
# write tab_completion.sh with erb
|
81
|
+
#
|
82
|
+
def update_tab_completion(target)
|
83
|
+
words = `#{File.join BF, MarkdownExec::BIN_NAME} --tab-completions`.split("\n")
|
84
|
+
mde_tab_completions = "(#{words_list(words)})"
|
85
|
+
mde_help = `#{File.join BF, MarkdownExec::BIN_NAME} --help`.split("\n")
|
86
|
+
menu_export_yaml = `#{File.join BF, MarkdownExec::BIN_NAME} --menu-export`
|
87
|
+
|
88
|
+
svhs = YAML.load menu_export_yaml # rubocop:disable Security/YAMLLoad
|
89
|
+
svhs.each do |svh|
|
90
|
+
svh[:compreply] = value_for_cli(svh[:default]) if svh[:compreply].nil?
|
91
|
+
end.tap_inspect name: :svhs, format: :yaml
|
92
|
+
|
93
|
+
File.write target, ERB.new(File.read(File.join(BF, 'tab_completion.sh.erb'))).result(binding)
|
94
|
+
end
|
95
|
+
|
96
|
+
desc 'update tab_completion.sh'
|
97
|
+
task :update_tab_completion do
|
98
|
+
update_tab_completion File.join(BF, 'tab_completion.sh')
|
99
|
+
end
|
100
|
+
|
101
|
+
desc 'update tab_completion.sh'
|
102
|
+
task :update_installed_tab_completion do
|
103
|
+
update_tab_completion(fs = File.join(`mde --pwd`.chomp, BF, 'tab_completion.sh'))
|
104
|
+
|
105
|
+
puts `cat #{fs}` ###
|
106
|
+
end
|
data/bin/tab_completion.sh
CHANGED
@@ -4,20 +4,148 @@ __filedirs()
|
|
4
4
|
{
|
5
5
|
local IFS=$'\n'
|
6
6
|
COMPREPLY=( $(compgen -o plusdirs -f -- "${cur}") )
|
7
|
+
# COMPREPLY=( $(compgen -d) $(compgen -f -- "${cur}") )
|
8
|
+
}
|
9
|
+
|
10
|
+
__filedirs_all()
|
11
|
+
{
|
12
|
+
COMPREPLY='.'
|
13
|
+
}
|
14
|
+
|
15
|
+
_mde_echo_version() {
|
16
|
+
echo "1.2.0"
|
7
17
|
}
|
8
18
|
|
9
19
|
_mde() {
|
10
20
|
local cur prev opts
|
11
21
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
12
22
|
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
13
|
-
|
23
|
+
# printf '%s' "-;${prev}-:${cur}-"
|
14
24
|
|
25
|
+
# current word is an option type
|
26
|
+
# if previous word is an option name
|
27
|
+
# stage 2: replace with option default value
|
28
|
+
#
|
29
|
+
if [[ "${cur}" =~ ^\..+\.$ ]] ; then
|
30
|
+
if [[ ${prev} == -* ]] ; then
|
31
|
+
case $prev in
|
32
|
+
|
33
|
+
--config) COMPREPLY="."; return 0 ;;
|
34
|
+
|
35
|
+
--debug) COMPREPLY="0"; return 0 ;;
|
36
|
+
|
37
|
+
--display-level) COMPREPLY="1"; return 0 ;;
|
38
|
+
|
39
|
+
--filename) COMPREPLY="."; return 0 ;;
|
40
|
+
|
41
|
+
--list-count) COMPREPLY="32"; return 0 ;;
|
42
|
+
|
43
|
+
--logged-stdout-filename-prefix) COMPREPLY="mde"; return 0 ;;
|
44
|
+
|
45
|
+
--menu-blocks-with-docname) COMPREPLY="0"; return 0 ;;
|
46
|
+
|
47
|
+
--menu-blocks-with-headings) COMPREPLY="0"; return 0 ;;
|
48
|
+
|
49
|
+
--output-execution-summary) COMPREPLY="0"; return 0 ;;
|
50
|
+
|
51
|
+
--output-script) COMPREPLY="0"; return 0 ;;
|
52
|
+
|
53
|
+
--output-stdout) COMPREPLY="1"; return 0 ;;
|
54
|
+
|
55
|
+
--path) COMPREPLY="."; return 0 ;;
|
56
|
+
|
57
|
+
--save-executed-script) COMPREPLY="0"; return 0 ;;
|
58
|
+
|
59
|
+
--save-execution-output) COMPREPLY="0"; return 0 ;;
|
60
|
+
|
61
|
+
--saved-script-chmod) COMPREPLY="493"; return 0 ;;
|
62
|
+
|
63
|
+
--saved-script-filename-prefix) COMPREPLY="mde"; return 0 ;;
|
64
|
+
|
65
|
+
--saved-script-folder) COMPREPLY="logs"; return 0 ;;
|
66
|
+
|
67
|
+
--saved-script-glob) COMPREPLY="mde_\*.sh"; return 0 ;;
|
68
|
+
|
69
|
+
--saved-stdout-folder) COMPREPLY="logs"; return 0 ;;
|
70
|
+
|
71
|
+
--saved-stdout-glob) COMPREPLY="mde_\*.out.txt"; return 0 ;;
|
72
|
+
|
73
|
+
--user-must-approve) COMPREPLY="1"; return 0 ;;
|
74
|
+
|
75
|
+
esac
|
76
|
+
fi
|
77
|
+
fi
|
78
|
+
|
79
|
+
# current word is an option name or start of
|
80
|
+
# present matching option names
|
81
|
+
#
|
15
82
|
if [[ ${cur} == -* ]] ; then
|
16
|
-
|
83
|
+
opts=("--list-blocks" "--list-default-env" "--list-default-yaml" "--list-docs" "--list-recent-output" "--list-recent-scripts" "--pwd" "--run-last-script" "--select-recent-output" "--select-recent-script" "--menu-export" "--tab-completions" "--help" "--version" "--exit" "--config" "--debug" "--display-level" "--block-name" "--filename" "--list-count" "--logged-stdout-filename-prefix" "--menu-blocks-with-docname" "--menu-blocks-with-headings" "--output-execution-summary" "--output-script" "--output-stdout" "--path" "--save-executed-script" "--save-execution-output" "--saved-script-chmod" "--saved-script-filename-prefix" "--saved-script-folder" "--saved-script-glob" "--saved-stdout-folder" "--saved-stdout-glob" "--user-must-approve")
|
84
|
+
COMPREPLY=( $(compgen -W "$(printf "'%s' " "${opts[@]}")" -- "${cur}") )
|
85
|
+
|
17
86
|
return 0
|
18
87
|
fi
|
19
88
|
|
89
|
+
# no current word
|
90
|
+
# if previous word is an option name
|
91
|
+
# stage 1: present option type
|
92
|
+
#
|
93
|
+
if [[ -z ${cur} ]] ; then
|
94
|
+
case $prev in
|
95
|
+
|
96
|
+
--config) COMPREPLY=".PATH."; return 0 ;;
|
97
|
+
|
98
|
+
--debug) COMPREPLY=".BOOL."; return 0 ;;
|
99
|
+
|
100
|
+
--display-level) COMPREPLY=".INT.0-2."; return 0 ;;
|
101
|
+
|
102
|
+
--block-name) COMPREPLY=".NAME."; return 0 ;;
|
103
|
+
|
104
|
+
--filename) COMPREPLY=".RELATIVE_PATH."; return 0 ;;
|
105
|
+
|
106
|
+
--list-count) COMPREPLY=".INT.1-."; return 0 ;;
|
107
|
+
|
108
|
+
--logged-stdout-filename-prefix) COMPREPLY=".PREFIX."; return 0 ;;
|
109
|
+
|
110
|
+
--menu-blocks-with-docname) COMPREPLY=".BOOL."; return 0 ;;
|
111
|
+
|
112
|
+
--menu-blocks-with-headings) COMPREPLY=".BOOL."; return 0 ;;
|
113
|
+
|
114
|
+
--output-execution-summary) COMPREPLY=".BOOL."; return 0 ;;
|
115
|
+
|
116
|
+
--output-script) COMPREPLY=".BOOL."; return 0 ;;
|
117
|
+
|
118
|
+
--output-stdout) COMPREPLY=".BOOL."; return 0 ;;
|
119
|
+
|
120
|
+
--path) COMPREPLY=".RELATIVE_PATH."; return 0 ;;
|
121
|
+
|
122
|
+
--save-executed-script) COMPREPLY=".BOOL."; return 0 ;;
|
123
|
+
|
124
|
+
--save-execution-output) COMPREPLY=".BOOL."; return 0 ;;
|
125
|
+
|
126
|
+
--saved-script-chmod) COMPREPLY=".INT."; return 0 ;;
|
127
|
+
|
128
|
+
--saved-script-filename-prefix) COMPREPLY=".PREFIX."; return 0 ;;
|
129
|
+
|
130
|
+
--saved-script-folder) COMPREPLY=".RELATIVE_PATH."; return 0 ;;
|
131
|
+
|
132
|
+
--saved-script-glob) COMPREPLY=".GLOB."; return 0 ;;
|
133
|
+
|
134
|
+
--saved-stdout-folder) COMPREPLY=".RELATIVE_PATH."; return 0 ;;
|
135
|
+
|
136
|
+
--saved-stdout-glob) COMPREPLY=".GLOB."; return 0 ;;
|
137
|
+
|
138
|
+
--user-must-approve) COMPREPLY=".BOOL."; return 0 ;;
|
139
|
+
|
140
|
+
esac
|
141
|
+
fi
|
142
|
+
|
143
|
+
# current word is unrecognized
|
144
|
+
# present matching directory or file names
|
145
|
+
#
|
20
146
|
__filedirs
|
21
147
|
}
|
22
148
|
|
23
|
-
complete -o filenames -F _mde mde
|
149
|
+
complete -o filenames -o nospace -F _mde mde
|
150
|
+
# _mde_echo_version
|
151
|
+
# echo "Updated: 2022-06-12 20:31:36 UTC"
|
@@ -0,0 +1,85 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
__filedirs()
|
4
|
+
{
|
5
|
+
local IFS=$'\n'
|
6
|
+
COMPREPLY=( $(compgen -o plusdirs -f -- "${cur}") )
|
7
|
+
# COMPREPLY=( $(compgen -d) $(compgen -f -- "${cur}") )
|
8
|
+
}
|
9
|
+
|
10
|
+
__filedirs_all()
|
11
|
+
{
|
12
|
+
COMPREPLY='.'
|
13
|
+
}
|
14
|
+
|
15
|
+
_mde_echo_version() {
|
16
|
+
echo "<%= MarkdownExec::VERSION %>"
|
17
|
+
}
|
18
|
+
|
19
|
+
_mde() {
|
20
|
+
local cur prev opts
|
21
|
+
cur="${COMP_WORDS[COMP_CWORD]}"
|
22
|
+
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
23
|
+
# printf '%s' "-;${prev}-:${cur}-"
|
24
|
+
|
25
|
+
# current word is an option type
|
26
|
+
# if previous word is an option name
|
27
|
+
# stage 2: replace with option default value
|
28
|
+
#
|
29
|
+
if [[ "${cur}" =~ ^\..+\.$ ]] ; then
|
30
|
+
if [[ ${prev} == -* ]] ; then
|
31
|
+
case $prev in
|
32
|
+
<% svhs.each do |svh|
|
33
|
+
svn = svh[:long_name]
|
34
|
+
if svn && svh[:arg_name]
|
35
|
+
svn = '--' + svh[:long_name]
|
36
|
+
if svh[:compreply] == false
|
37
|
+
# nothing
|
38
|
+
elsif svh[:compreply].nil? %>
|
39
|
+
<%= svn + ') __filedirs_all; return 0 ;;' %>
|
40
|
+
<% elsif svh[:compreply].empty?
|
41
|
+
# nothing
|
42
|
+
else %>
|
43
|
+
<%= svn + ') COMPREPLY="' + svh[:compreply] + '"; return 0 ;;' %>
|
44
|
+
<% end
|
45
|
+
end
|
46
|
+
end %>
|
47
|
+
esac
|
48
|
+
fi
|
49
|
+
fi
|
50
|
+
|
51
|
+
# current word is an option name or start of
|
52
|
+
# present matching option names
|
53
|
+
#
|
54
|
+
if [[ ${cur} == -* ]] ; then
|
55
|
+
opts=<%= mde_tab_completions %>
|
56
|
+
COMPREPLY=( $(compgen -W "$(printf "'%s' " "${opts[@]}")" -- "${cur}") )
|
57
|
+
|
58
|
+
return 0
|
59
|
+
fi
|
60
|
+
|
61
|
+
# no current word
|
62
|
+
# if previous word is an option name
|
63
|
+
# stage 1: present option type
|
64
|
+
#
|
65
|
+
if [[ -z ${cur} ]] ; then
|
66
|
+
case $prev in
|
67
|
+
<% svhs.each do |svh|
|
68
|
+
svn = svh[:long_name]
|
69
|
+
if svn && svh[:arg_name]
|
70
|
+
svn = '--' + svh[:long_name] %>
|
71
|
+
<%= svn + ') COMPREPLY=".' + svh[:arg_name] + '."; return 0 ;;' %>
|
72
|
+
<% end
|
73
|
+
end %>
|
74
|
+
esac
|
75
|
+
fi
|
76
|
+
|
77
|
+
# current word is unrecognized
|
78
|
+
# present matching directory or file names
|
79
|
+
#
|
80
|
+
__filedirs
|
81
|
+
}
|
82
|
+
|
83
|
+
complete -o filenames -o nospace -F _mde mde
|
84
|
+
# _mde_echo_version
|
85
|
+
# echo "Updated: <%= Time.now.utc %>"
|
data/lib/colorize.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# encoding=utf-8
|
4
|
+
|
5
|
+
# │0 │ to restore default │
|
6
|
+
# │ │ color │
|
7
|
+
# ├───┼───────────────────────┤
|
8
|
+
# │ │ │
|
9
|
+
# │1 │ for brighter colors │
|
10
|
+
# ├───┼───────────────────────┤
|
11
|
+
# │ │ │
|
12
|
+
# │4 │ for underlined text │
|
13
|
+
# ├───┼───────────────────────┤
|
14
|
+
# │ │ │
|
15
|
+
# │5 │ for flashing text
|
16
|
+
class String
|
17
|
+
def black
|
18
|
+
"\033[30m#{self}\033[0m"
|
19
|
+
end
|
20
|
+
|
21
|
+
def red
|
22
|
+
"\033[31m#{self}\033[0m"
|
23
|
+
end
|
24
|
+
|
25
|
+
def bred
|
26
|
+
"\033[1;31m#{self}\033[0m"
|
27
|
+
end
|
28
|
+
|
29
|
+
def green
|
30
|
+
"\033[32m#{self}\033[0m"
|
31
|
+
end
|
32
|
+
|
33
|
+
def bgreen
|
34
|
+
"\033[1;32m#{self}\033[0m"
|
35
|
+
end
|
36
|
+
|
37
|
+
def yellow
|
38
|
+
"\033[33m#{self}\033[0m"
|
39
|
+
end
|
40
|
+
|
41
|
+
def byellow
|
42
|
+
"\033[1;33m#{self}\033[0m"
|
43
|
+
end
|
44
|
+
|
45
|
+
def blue
|
46
|
+
"\033[34m#{self}\033[0m"
|
47
|
+
end
|
48
|
+
|
49
|
+
def magenta
|
50
|
+
"\033[35m#{self}\033[0m"
|
51
|
+
end
|
52
|
+
|
53
|
+
def cyan
|
54
|
+
"\033[36m#{self}\033[0m"
|
55
|
+
end
|
56
|
+
|
57
|
+
def white
|
58
|
+
"\033[37m#{self}\033[0m"
|
59
|
+
end
|
60
|
+
|
61
|
+
def bwhite
|
62
|
+
"\033[1;37m#{self}\033[0m"
|
63
|
+
end
|
64
|
+
end
|