markdown_exec 2.8.5 → 3.0.0
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/CHANGELOG.md +18 -1
- data/Gemfile.lock +1 -1
- data/Rakefile +0 -33
- data/bats/bats.bats +2 -0
- data/bats/block-type-link.bats +1 -1
- data/bats/block-type-ux-allowed.bats +2 -2
- data/bats/block-type-ux-invalid.bats +1 -1
- data/bats/{block-type-ux-preconditions.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 +36 -0
- data/bats/border.bats +1 -1
- data/bats/cli.bats +2 -2
- data/bats/command-substitution-options.bats +14 -0
- data/bats/command-substitution.bats +1 -1
- data/bats/fail.bats +5 -2
- data/bats/indented-block-type-vars.bats +1 -1
- data/bats/markup.bats +1 -1
- data/bats/option-expansion.bats +8 -0
- data/bats/table-column-truncate.bats +1 -1
- data/bats/test_helper.bash +50 -5
- data/docs/dev/bats-document-configuration.md +1 -1
- data/docs/dev/block-type-ux-allowed.md +5 -7
- data/docs/dev/block-type-ux-auto.md +8 -5
- data/docs/dev/block-type-ux-chained.md +4 -2
- data/docs/dev/block-type-ux-echo-hash.md +6 -7
- data/docs/dev/block-type-ux-echo.md +2 -2
- data/docs/dev/block-type-ux-exec.md +3 -5
- data/docs/dev/block-type-ux-hidden.md +3 -0
- data/docs/dev/{block-type-ux-preconditions.md → block-type-ux-required-variables.md} +1 -2
- data/docs/dev/block-type-ux-row-format.md +3 -4
- data/docs/dev/block-type-ux-sources.md +57 -0
- data/docs/dev/block-type-ux-transform.md +0 -4
- data/docs/dev/command-substitution-options.md +61 -0
- data/docs/dev/indented-block-type-vars.md +1 -0
- data/docs/dev/menu-pagination-indent.md +123 -0
- data/docs/dev/menu-pagination.md +111 -0
- data/docs/dev/option-expansion.md +10 -0
- data/lib/ansi_formatter.rb +2 -0
- data/lib/block_cache.rb +197 -0
- data/lib/command_result.rb +57 -0
- data/lib/constants.rb +18 -0
- data/lib/error_reporting.rb +38 -0
- data/lib/evaluate_shell_expressions.rb +43 -18
- data/lib/fcb.rb +98 -7
- data/lib/hash_delegator.rb +526 -322
- data/lib/markdown_exec/version.rb +1 -1
- data/lib/markdown_exec.rb +136 -45
- data/lib/mdoc.rb +59 -10
- data/lib/menu.src.yml +23 -11
- data/lib/menu.yml +22 -12
- data/lib/value_or_exception.rb +76 -0
- metadata +16 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5fce77c3fa5686b583f500f1f5afafcb21903c323dcb5466662130e240581957
|
4
|
+
data.tar.gz: 0cb414335a8df51349d7fac27da3ab7d1b79af81af8f104605d1c2158b8067cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef7aed19a54e257e07dee6d7b9cef11062c68fb35aad42bcba9a33584086eb7b1016523dc013bb2bc88c34d0349190d4f9ca9b2e524daf086e4eae4bbf8b4d5b
|
7
|
+
data.tar.gz: '08530d2e5f303fd6743dcbf9aaec45f375c91e4895541e4a466621401c4147954c498c4c72c570b1e2a34faee9bcfa58fe1434708c44b55f749fff854a54f4dd'
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,22 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [3.0.0] - 2025-05-20
|
4
|
+
|
5
|
+
### Added
|
6
|
+
|
7
|
+
- UX block keys 'act' and 'init' specify initial and activation behavior.
|
8
|
+
- Inactive targets in long blocks of text to smooth navigation.
|
9
|
+
- Options to display configuration keys and values similar to other shell expansions.
|
10
|
+
|
11
|
+
### Changed
|
12
|
+
|
13
|
+
- Rename UX block key 'default' to 'init' except when used in a prompt for input from the user.
|
14
|
+
- Rename UX block keys 'allow', 'format', 'require'.
|
15
|
+
- Handle user selecting 'Back' when saving.
|
16
|
+
- Modify internal block IDs.
|
17
|
+
- Remove extraneous final newline in output.
|
18
|
+
- UX block required variables are temporary for evaluation.
|
19
|
+
|
3
20
|
## [2.8.5] - 2025-04-07
|
4
21
|
|
5
22
|
### Added
|
@@ -71,7 +88,7 @@
|
|
71
88
|
|
72
89
|
### Added
|
73
90
|
|
74
|
-
- UX blocks can
|
91
|
+
- UX blocks can specify required variables. The variables must be present before the UX block is executed. If any required variables are not set, a warning is displayed, and the sequence is aborted.
|
75
92
|
- UX blocks can require shell an other UX blocks.
|
76
93
|
- UX blocks are evaluated in order and calculation can depend on prior variables in the same sequence.
|
77
94
|
|
data/Gemfile.lock
CHANGED
data/Rakefile
CHANGED
@@ -127,8 +127,6 @@ task :minitest do
|
|
127
127
|
'./lib/dev/hierarchy.rb --verbose',
|
128
128
|
'./lib/dev/process_command.rb --verbose',
|
129
129
|
'./lib/dev/process_template.rb --test --verbose',
|
130
|
-
# './lib/dev/ruby_file_processor.rb --test --verbose',
|
131
|
-
# './lib/dev/std_out_err_logger.rb', ### errs
|
132
130
|
'./lib/dev/visibility-controller.rb --verbose',
|
133
131
|
'./lib/directory_searcher.rb --verbose',
|
134
132
|
'./lib/evaluate_shell_expressions.rb --verbose',
|
@@ -147,7 +145,6 @@ task :minitest do
|
|
147
145
|
'./lib/resize_terminal.rb --verbose',
|
148
146
|
'./lib/saved_assets.rb --verbose',
|
149
147
|
'./lib/saved_files_matcher.rb --verbose',
|
150
|
-
# './lib/shell_session.rb --verbose',
|
151
148
|
'./lib/table_extractor.rb --verbose',
|
152
149
|
'./lib/text_analyzer.rb --verbose'
|
153
150
|
]
|
@@ -258,33 +255,3 @@ def words_list(words)
|
|
258
255
|
%("#{word}")
|
259
256
|
end.join ' '
|
260
257
|
end
|
261
|
-
|
262
|
-
desc 'Build the Docker image for MarkdownExec'
|
263
|
-
task :docker_build do
|
264
|
-
dockerfile = 'Dockerfile.ruby-3.3'
|
265
|
-
image_tag = "mde-#{MarkdownExec::VERSION}.gem"
|
266
|
-
|
267
|
-
command = [
|
268
|
-
"docker build",
|
269
|
-
"--build-arg VERSION=#{MarkdownExec::VERSION}",
|
270
|
-
"-f #{dockerfile}",
|
271
|
-
"-t #{image_tag}",
|
272
|
-
"."
|
273
|
-
].join(' ')
|
274
|
-
|
275
|
-
puts "Building Docker image: #{image_tag} using #{dockerfile}..."
|
276
|
-
puts system(command) || abort("Docker build failed. Please check the output for details.")
|
277
|
-
end
|
278
|
-
|
279
|
-
desc 'Launch an interactive Docker Bash shell'
|
280
|
-
task :docker_exec do
|
281
|
-
exec "docker exec -it mde-#{MarkdownExec::VERSION}.gem bash"
|
282
|
-
end
|
283
|
-
|
284
|
-
desc 'Run the mde binary inside a Docker container. eg `docker_run -- args`'
|
285
|
-
task :docker_run, [:args] do
|
286
|
-
args = ARGV.dup
|
287
|
-
args.shift
|
288
|
-
args.shift if args[0] == '--'
|
289
|
-
exec "docker run -it mde-#{MarkdownExec::VERSION}.gem mde #{args.join(' ')}"
|
290
|
-
end
|
data/bats/bats.bats
CHANGED
data/bats/block-type-link.bats
CHANGED
@@ -4,6 +4,6 @@ load 'test_helper'
|
|
4
4
|
|
5
5
|
@test 'Link blocks - set variable in link block; call hidden block' {
|
6
6
|
# __Exit is required as last block is a Link type
|
7
|
-
run_mde_specs_md_args_expect_xansi '[VARIABLE1]'
|
7
|
+
run_mde_specs_md_args_expect_xansi '[VARIABLE1]' $EXIT_MENU ' VARIABLE1: 1'
|
8
8
|
run_mde_specs_md_args_expect_xansi '[VARIABLE1]' '(echo-VARIABLE1)' ' VARIABLE1: 1 VARIABLE1: 1'
|
9
9
|
}
|
@@ -4,14 +4,14 @@ load 'test_helper'
|
|
4
4
|
|
5
5
|
@test 'automatic blocks load defaults - constants or first allowed from output of echo or exec' {
|
6
6
|
spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-ux-allowed.md \
|
7
|
-
'SPECIES=Pongo tapanuliensis_GENUS=Pongo_FAMILY=_ORDER
|
7
|
+
'SPECIES=Pongo tapanuliensis_GENUS=Pongo_FAMILY=_ORDER: Click to select..._Click to select..._YEAR_DISCOVERED=_NAME=Tapanuli Orangutan'
|
8
8
|
}
|
9
9
|
|
10
10
|
@test 'executing a block loads the first allowed value' {
|
11
11
|
skip 'Unable to test the menu presented'
|
12
12
|
spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-ux-allowed.md \
|
13
13
|
'[FAMILY]' \
|
14
|
-
'SPECIES=Pongo tapanuliensis_GENUS=Pongo_FAMILY=
|
14
|
+
'SPECIES=Pongo tapanuliensis_GENUS=Pongo_FAMILY=Hominidae_Click to select...Click to select..._YEAR_DISCOVERED=_NAME='
|
15
15
|
}
|
16
16
|
|
17
17
|
@test 'executing a block loads the first line in the output of exec' {
|
@@ -4,5 +4,5 @@ load 'test_helper'
|
|
4
4
|
|
5
5
|
@test 'automatic block is invalid YAML' {
|
6
6
|
spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-ux-invalid.md \
|
7
|
-
'_Error: HashDelegator../docs/dev/block-type-ux-invalid.
|
7
|
+
'_Error: HashDelegator../docs/dev/block-type-ux-invalid.md¤ItrBlkFrmNstFls:1 - --- !ruby/object:NullResult_message: Invalid YAML_data: invalid_ -- -- '
|
8
8
|
}
|
@@ -3,6 +3,6 @@
|
|
3
3
|
load 'test_helper'
|
4
4
|
|
5
5
|
@test 'An undefined variable is a precondition' {
|
6
|
-
spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-ux-
|
6
|
+
spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-ux-required-variables.md \
|
7
7
|
'A value must exist for: MISSING_VARIABLE_SPECIES='
|
8
8
|
}
|
@@ -4,5 +4,5 @@ load 'test_helper'
|
|
4
4
|
|
5
5
|
@test 'Row format merges with prior table' {
|
6
6
|
spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-ux-row-format.md \
|
7
|
-
|
7
|
+
" | Variable | Value | Prompt |_ | ---------- | -------------------- | --------------------- |_ | Species | Pongo tapanuliensis | New species? |_ | Name: Genu | Value: Xform: 'Pongo | Prompt: New genus? |_ | Family | Hominidae | Enter a value: |"
|
8
8
|
}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
#!/usr/bin/env bats
|
2
|
+
|
3
|
+
load 'test_helper'
|
4
|
+
|
5
|
+
@test 'dname' {
|
6
|
+
spec_mde_xansi_message_doc_blocks_expect docs/dev/block-type-ux-sources.md \
|
7
|
+
dname \
|
8
|
+
'USER_NAME=Guest_CURRENT_DIR=markdown_exec_SHELL_VERSION=/bin/bash_ENVIRONMENT=development_USER_EMAIL=_VERSION='
|
9
|
+
}
|
10
|
+
|
11
|
+
@test 'init_source' {
|
12
|
+
spec_mde_xansi_message_doc_blocks_expect docs/dev/block-type-ux-sources.md \
|
13
|
+
export_init \
|
14
|
+
'default_exec_echo_allow_false_false'
|
15
|
+
}
|
16
|
+
|
17
|
+
@test 'act_source' {
|
18
|
+
spec_mde_xansi_message_doc_blocks_expect docs/dev/block-type-ux-sources.md \
|
19
|
+
export_act \
|
20
|
+
'edit_edit_edit_allow_edit_edit'
|
21
|
+
}
|
22
|
+
|
23
|
+
@test 'is_disabled?' {
|
24
|
+
spec_mde_xansi_message_doc_blocks_expect docs/dev/block-type-ux-sources.md \
|
25
|
+
is_disabled? \
|
26
|
+
'false_false_false_false_false_false'
|
27
|
+
}
|
28
|
+
|
29
|
+
# test trigger presents prompt
|
30
|
+
# test trigger presents allow list
|
31
|
+
# test validation limits input
|
32
|
+
# test transform formats output
|
33
|
+
# test format creates output
|
34
|
+
# test default, validation, prompt are displayed
|
35
|
+
|
36
|
+
# bin/bmde docs/dev/block-type-ux-sources.md --list-blocks-message init_source --list-blocks-type 3 --list-blocks
|
data/bats/border.bats
CHANGED
data/bats/cli.bats
CHANGED
@@ -39,14 +39,14 @@ load 'test_helper'
|
|
39
39
|
# the last block is a link block, so menu is displayed
|
40
40
|
@test 'link block setting an environment variable requires a bash block' {
|
41
41
|
BATS_OUTPUT_FILTER=A
|
42
|
-
spec_mde_args_expect docs/dev/requiring-blocks.md '[link-local-block-with-vars]'
|
42
|
+
spec_mde_args_expect docs/dev/requiring-blocks.md '[link-local-block-with-vars]' $EXIT_MENU \
|
43
43
|
' ARG1: 37'
|
44
44
|
}
|
45
45
|
|
46
46
|
# the last block is a link block, so menu is displayed
|
47
47
|
@test 'link block setting an environment variable calls a bash block in a file' {
|
48
48
|
BATS_OUTPUT_FILTER=A
|
49
|
-
spec_mde_args_expect docs/dev/requiring-blocks.md '[link-file-block-with-vars]'
|
49
|
+
spec_mde_args_expect docs/dev/requiring-blocks.md '[link-file-block-with-vars]' $EXIT_MENU \
|
50
50
|
' ARG1: arg1-from-link-file'
|
51
51
|
}
|
52
52
|
|
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env bats
|
2
|
+
|
3
|
+
load 'test_helper'
|
4
|
+
|
5
|
+
@test 'Operator $' {
|
6
|
+
spec_mde_xansi_dname_doc_blocks_expect docs/dev/command-substitution-options.md \
|
7
|
+
'operator_$' \
|
8
|
+
'Command substitution__The current value of environment variable Common_Name_is displayed using two different operators._The command echo $SHLVL is executed via command_substitution, using two different operators.__| Operato | Variable Expansio | Command Substitutio |_| ------- | ----------------- | ------------------- |_| $ | Tapanuli Oranguta | Pongo tapanuliensis |_| @ | @{Common_Name} | @(echo $Species) |__Toggle between operators.__operator_$__operator_@'
|
9
|
+
}
|
10
|
+
|
11
|
+
@test 'Operator @' {
|
12
|
+
spec_mde_xansi_dname_doc_blocks_expect docs/dev/command-substitution-options.md \
|
13
|
+
'Command substitution__The current value of environment variable Common_Name_is displayed using two different operators._The command echo $SHLVL is executed via command_substitution, using two different operators.__| Operato | Variable Expansio | Command Substitutio |_| ------- | ----------------- | ------------------- |_| $ | ${Common_Name} | $(echo $Species) |_| @ | Tapanuli Oranguta | Pongo tapanuliensis |__Toggle between operators.__operator_$__operator_@'
|
14
|
+
}
|
@@ -4,5 +4,5 @@ load 'test_helper'
|
|
4
4
|
|
5
5
|
@test 'Command substitution' {
|
6
6
|
spec_mde_xansi_dname_doc_blocks_expect docs/dev/command-substitution.md \
|
7
|
-
'CURRENT BASE NAME IS: MARKDOWN_EXEC_current base name is: markdown_exec_current base name is: markdown_exec_| current base name |_| ----------------- |_| markdown_exec |_: notice the string is not expanded in Shell block types (names or body).
|
7
|
+
'CURRENT BASE NAME IS: MARKDOWN_EXEC_current base name is: markdown_exec_current base name is: markdown_exec_| current base name |_| ----------------- |_| markdown_exec |_: notice the string is not expanded in Shell block types (names or body)._echo "current base name is now $(basename `pwd`)"_load: file_markdown_exec.sh_Status not zero: $(err)'
|
8
8
|
}
|
data/bats/fail.bats
CHANGED
@@ -2,10 +2,13 @@
|
|
2
2
|
|
3
3
|
load 'test_helper'
|
4
4
|
|
5
|
+
# this file contains a test that fails.
|
6
|
+
# this file is skipped during code checks.
|
7
|
+
|
5
8
|
@test 'FAIL' {
|
6
|
-
run_mde_specs_md_args_expect_xansi '[VARIABLE1]'
|
9
|
+
run_mde_specs_md_args_expect_xansi '[VARIABLE1]' $EXIT_MENU ' VARIABLE1: FAIL'
|
7
10
|
}
|
8
11
|
|
9
12
|
@test 'OK' {
|
10
|
-
run_mde_specs_md_args_expect_xansi '[VARIABLE1]'
|
13
|
+
run_mde_specs_md_args_expect_xansi '[VARIABLE1]' $EXIT_MENU ' VARIABLE1: 1'
|
11
14
|
}
|
@@ -5,5 +5,5 @@ load 'test_helper'
|
|
5
5
|
@test 'an indented block with multiple lines' {
|
6
6
|
BATS_OUTPUT_FILTER=A
|
7
7
|
spec_mde_xansi_dname_doc_blocks_expect docs/dev/indented-block-type-vars.md \
|
8
|
-
' Species: Pongo tapanuliensis_ Genus:
|
8
|
+
' Species: Pongo tapanuliensis_ Genus: Pongo'
|
9
9
|
}
|
data/bats/markup.bats
CHANGED
@@ -0,0 +1,8 @@
|
|
1
|
+
#!/usr/bin/env bats
|
2
|
+
|
3
|
+
load 'test_helper'
|
4
|
+
|
5
|
+
@test '' {
|
6
|
+
spec_mde_xansi_dname_doc_blocks_expect docs/dev/option-expansion.md \
|
7
|
+
'_| Optio | Description | Value | Va | Def |_| ----- | -------------------------------- | ----- | -- | --- |_| scree | Screen width for document and in | 2 | 64 | 0 |_| table | | 5 | fa | tru |'
|
8
|
+
}
|
@@ -4,5 +4,5 @@ load 'test_helper'
|
|
4
4
|
|
5
5
|
@test 'Tables - truncate columns' {
|
6
6
|
spec_mde_xansi_dname_doc_blocks_expect docs/dev/table-column-truncate.md \
|
7
|
-
'DEMONSTRATE TRUNCATION OF TEXT IN TABLE CELLS__| Common Name | Species | Genus | Family | Year Di |_| ------------ | ------------ | ----- | ------- | ------- |_| Tapanuli Ora | Pongo tapanu | Pongo | Hominid | 2017 |_| Psychedelic | Histiophryne | Histi | Antenna | 2009 |_| Ruby Seadrag | Phyllopteryx | Phyll | Syngnat | 2015 |_| Illacme tobi | Illacme tobi | Illac | Siphono | 2016 |_| Spiny Dandel | Taraxacum ja | Tarax | Asterac | 2022 |
|
7
|
+
'DEMONSTRATE TRUNCATION OF TEXT IN TABLE CELLS__| Common Name | Species | Genus | Family | Year Di |_| ------------ | ------------ | ----- | ------- | ------- |_| Tapanuli Ora | Pongo tapanu | Pongo | Hominid | 2017 |_| Psychedelic | Histiophryne | Histi | Antenna | 2009 |_| Ruby Seadrag | Phyllopteryx | Phyll | Syngnat | 2015 |_| Illacme tobi | Illacme tobi | Illac | Siphono | 2016 |_| Spiny Dandel | Taraxacum ja | Tarax | Asterac | 2022 |_'
|
8
8
|
}
|
data/bats/test_helper.bash
CHANGED
@@ -1,5 +1,35 @@
|
|
1
1
|
# facilitate execution of program, comparison of output
|
2
2
|
|
3
|
+
EXIT_MENU=__Exit # name of menu Exit option
|
4
|
+
|
5
|
+
# Compare two byte sequences (strings or files) and report each difference:
|
6
|
+
# • zero-based byte offset
|
7
|
+
# • expected byte (0xHEX) and printable character (or “.”)
|
8
|
+
# • actual byte (0xHEX) and printable character (or “.”)
|
9
|
+
compare_bytes () {
|
10
|
+
set +e
|
11
|
+
local mode="$1"; shift
|
12
|
+
if [[ "$mode" == "--file" ]]; then
|
13
|
+
local f1="$1" f2="$2"
|
14
|
+
exec 3<"$f1" 4<"$f2"
|
15
|
+
# read raw bytes from file descriptors 3 and 4
|
16
|
+
cmp --verbose /dev/fd/3 /dev/fd/4
|
17
|
+
else
|
18
|
+
local live="$mode" expect="$1"
|
19
|
+
# feed the two strings into cmp via process-substitution
|
20
|
+
cmp --verbose <(printf '%s' "$live") <(printf '%s' "$expect")
|
21
|
+
fi |
|
22
|
+
head -n 3 |
|
23
|
+
gawk '{
|
24
|
+
live = strtonum(0 $2)
|
25
|
+
expect = strtonum(0 $3)
|
26
|
+
offset = $1 - 1
|
27
|
+
printf "Offset 0x%X (%4d): output \"%c\" 0x%02X (%3d) vs expect \"%c\" 0x%02X (%3d)\n", \
|
28
|
+
offset, offset, live, live, live, expect, expect, expect
|
29
|
+
}'
|
30
|
+
set -e
|
31
|
+
}
|
32
|
+
|
3
33
|
date_from_history_file_name () {
|
4
34
|
basename "$1" | sed -E 's/.*([0-9]{4}-[0-9]{2}-[0-9]{2}).*/\1/'
|
5
35
|
}
|
@@ -13,23 +43,27 @@ echo_hexdump_expected_output_filter () {
|
|
13
43
|
local output="$2"
|
14
44
|
local filter="$3"
|
15
45
|
|
46
|
+
# print label, line, character count; output
|
16
47
|
echo -e "- output_$(echo "$output" | wc -l)_$(echo -n "$output" | wc -c):\n$output"
|
17
48
|
if [[ $filter == A ]]; then
|
49
|
+
# print label, line, character count; converted output
|
18
50
|
echo -e "- converted_$(echo "$output" | wc -l)_$(echo -n "$output" | wc -c):"
|
19
51
|
echo "$(remove_ansi_escape_sequences "$output")"
|
20
52
|
fi
|
53
|
+
# print label, line, character count; expected output
|
21
54
|
echo -e "- expected_$(echo "$expected" | wc -l)_$(echo -n "$expected" | wc -c):\n$expected"
|
22
55
|
|
23
56
|
if [[ $filter == A ]]; then
|
24
|
-
|
25
|
-
echo_hexdump "$output"
|
57
|
+
# print label and hex dump of converted output
|
26
58
|
echo "- converted"
|
27
59
|
echo_hexdump "$(remove_ansi_escape_sequences "$output")"
|
60
|
+
# print label and hex dump of expected output
|
28
61
|
echo "- expected"
|
29
62
|
echo_hexdump "$expected"
|
30
63
|
|
31
|
-
# print the byte offset of the first
|
32
|
-
|
64
|
+
# print the byte offset of the first few differences
|
65
|
+
echo "- offset"
|
66
|
+
compare_bytes "$(remove_ansi_escape_sequences "$output")" "$expected"
|
33
67
|
fi
|
34
68
|
}
|
35
69
|
|
@@ -210,8 +244,8 @@ spec_mde_args_grep_filter_expect () {
|
|
210
244
|
|
211
245
|
if ( ! expect_equal_with_conversion "$expected" "$output" "$filter"); then
|
212
246
|
echo_hexdump_expected_output_filter "$expected" "$output" "$filter"
|
247
|
+
return 1
|
213
248
|
fi
|
214
|
-
expect_equal_with_conversion "$expected" "$output" "$filter"
|
215
249
|
[[ -n $status ]] && echo "- status: $status"
|
216
250
|
[[ -n $status ]]
|
217
251
|
}
|
@@ -237,6 +271,17 @@ spec_mde_xansi_dname_doc_blocks_expect () {
|
|
237
271
|
"${!#}"
|
238
272
|
}
|
239
273
|
|
274
|
+
spec_mde_xansi_message_doc_blocks_expect () {
|
275
|
+
BATS_OUTPUT_FILTER=A
|
276
|
+
BATS_SAFE=_
|
277
|
+
spec_mde_args_expect "$1" \
|
278
|
+
"${@:3:$(($#-3))}" \
|
279
|
+
--list-blocks-message "$2" \
|
280
|
+
--list-blocks-type 3 \
|
281
|
+
--list-blocks \
|
282
|
+
"${!#}"
|
283
|
+
}
|
284
|
+
|
240
285
|
spec_mde_xansi_oname_doc_blocks_expect () {
|
241
286
|
BATS_OUTPUT_FILTER=A
|
242
287
|
BATS_SAFE=_
|
@@ -3,13 +3,11 @@
|
|
3
3
|
allowed:
|
4
4
|
- Pongo tapanuliensis
|
5
5
|
- Histiophryne psychedelica
|
6
|
-
default: :allowed
|
7
6
|
name: SPECIES
|
8
7
|
```
|
9
8
|
/ automatic block loads first line in output of exec
|
10
9
|
```ux :[document_ux_GENUS]
|
11
10
|
allowed: :exec
|
12
|
-
default: :allowed
|
13
11
|
exec: echo "Pongo\nHistiophryne psychedelica"
|
14
12
|
name: GENUS
|
15
13
|
```
|
@@ -18,7 +16,7 @@ name: GENUS
|
|
18
16
|
allowed:
|
19
17
|
- Hominidae
|
20
18
|
- Antennariidae
|
21
|
-
|
19
|
+
init: false
|
22
20
|
name: FAMILY
|
23
21
|
```
|
24
22
|
/ automatic block loads default value that is not in allowed list
|
@@ -26,13 +24,13 @@ name: FAMILY
|
|
26
24
|
allowed:
|
27
25
|
- Primates
|
28
26
|
- Lophiiformes
|
29
|
-
|
27
|
+
format: '%{name}: Click to select...'
|
30
28
|
name: ORDER
|
31
29
|
```
|
32
30
|
/ automatic block loads default value, not in allowed list from echo
|
33
31
|
```ux :[document_ux_CLASS]
|
34
32
|
allowed: :echo
|
35
|
-
|
33
|
+
format: Click to select...
|
36
34
|
echo: |
|
37
35
|
Mammalia
|
38
36
|
Actinopterygii
|
@@ -41,14 +39,14 @@ name: CLASS
|
|
41
39
|
/ executed block presents a menu of the lines in the output of exec
|
42
40
|
```ux :[YEAR_DISCOVERED]
|
43
41
|
allowed: :exec
|
44
|
-
|
42
|
+
init: false
|
43
|
+
prompt: ''
|
45
44
|
exec: echo "2017\n2009"
|
46
45
|
name: YEAR_DISCOVERED
|
47
46
|
```
|
48
47
|
/ automatic block presents a menu of the lines in the output of echo
|
49
48
|
```ux :[document_ux_NAME]
|
50
49
|
allowed: :echo
|
51
|
-
default: :allowed
|
52
50
|
echo: |
|
53
51
|
Tapanuli Orangutan
|
54
52
|
Psychedelic Frogfish
|
@@ -6,26 +6,28 @@ name: v1
|
|
6
6
|
/ name and default
|
7
7
|
/ transform and validate options not applied to default
|
8
8
|
```ux
|
9
|
-
|
9
|
+
init: false
|
10
10
|
echo: 11
|
11
11
|
name: v2
|
12
12
|
```
|
13
13
|
/ name and default; auto-load
|
14
14
|
/ prompt option is ignored during auto-load
|
15
15
|
```ux :[document_ux_v3]
|
16
|
-
|
16
|
+
init: :echo
|
17
|
+
echo: 12
|
17
18
|
name: v3
|
18
19
|
```
|
19
20
|
/ name, default, exec; auto-load static
|
20
21
|
```ux :[document_ux_v4]
|
21
|
-
|
22
|
+
init: :echo
|
23
|
+
echo: 21
|
22
24
|
exec: basename $(pwd)
|
23
25
|
name: v4
|
24
26
|
```
|
25
27
|
/ name, default, exec; auto-load executed `basename $(pwd)`
|
26
28
|
/ allowed is ignored by exec
|
27
29
|
```ux :[document_ux_v5]
|
28
|
-
|
30
|
+
init: :exec
|
29
31
|
exec: basename $(pwd)
|
30
32
|
name: v5
|
31
33
|
```
|
@@ -34,7 +36,8 @@ name: v5
|
|
34
36
|
allowed:
|
35
37
|
- 32
|
36
38
|
- 33
|
37
|
-
|
39
|
+
init: :echo
|
40
|
+
echo: 31
|
38
41
|
name: v6
|
39
42
|
```
|
40
43
|
@import bats-document-configuration.md
|
@@ -3,19 +3,21 @@
|
|
3
3
|
ENTITY='Pongo tapanuliensis,Pongo'
|
4
4
|
```
|
5
5
|
```ux :[SPECIES] +(shell) +(GENUS)
|
6
|
+
act: :echo
|
6
7
|
echo: "${ENTITY%%,*}"
|
8
|
+
init: false
|
7
9
|
name: SPECIES
|
8
10
|
```
|
9
11
|
/ required ux block requires another
|
10
12
|
```ux :(GENUS) +[NAME]
|
11
13
|
echo: "${ENTITY##*,}"
|
14
|
+
init: false
|
12
15
|
name: GENUS
|
13
|
-
readonly: true
|
14
16
|
```
|
15
17
|
/ executed in context of prior ux blocks, uses their values
|
16
18
|
```ux :[NAME]
|
17
19
|
echo: "$SPECIES - $GENUS"
|
20
|
+
init: false
|
18
21
|
name: NAME
|
19
|
-
readonly: true
|
20
22
|
```
|
21
23
|
@import bats-document-configuration.md
|
@@ -1,6 +1,5 @@
|
|
1
1
|
/ This automatic block sets multiple variables and displays the first variable.
|
2
2
|
```ux :[document_ux_BASENAME]
|
3
|
-
default: :echo
|
4
3
|
echo:
|
5
4
|
BASENAME: "$(basename `pwd`)"
|
6
5
|
DOCUMENTS: "${BASENAME%%_*}"
|
@@ -10,19 +9,19 @@ readonly: true
|
|
10
9
|
```
|
11
10
|
/ This block displays the second variable in the first block.
|
12
11
|
```ux :[DOCUMENTS]
|
13
|
-
|
12
|
+
init: false
|
14
13
|
name: DOCUMENTS
|
15
14
|
readonly: true
|
16
15
|
```
|
17
16
|
/ This block displays the third variable in the first block.
|
18
17
|
```ux :[OPERATION]
|
19
|
-
|
18
|
+
init: false
|
20
19
|
name: OPERATION
|
21
20
|
readonly: true
|
22
21
|
```
|
23
22
|
/ Multiple UX blocks to set many variables for a specific name.
|
24
23
|
```ux
|
25
|
-
|
24
|
+
init: false
|
26
25
|
echo:
|
27
26
|
Species: Pongo tapanuliensis
|
28
27
|
Genus: Pongo
|
@@ -37,7 +36,7 @@ menu_format: 'Load %{name}'
|
|
37
36
|
name: Tapanuli Orangutan
|
38
37
|
```
|
39
38
|
```ux
|
40
|
-
|
39
|
+
init: false
|
41
40
|
echo:
|
42
41
|
Species: Histiophryne psychedelica
|
43
42
|
Genus: Histiophryne
|
@@ -56,7 +55,7 @@ name: Psychedelic Frogfish
|
|
56
55
|
| -| -
|
57
56
|
/ A read-only variable in a UX block in a table
|
58
57
|
```ux
|
59
|
-
|
58
|
+
init: false
|
60
59
|
menu_format: '| %{name}| ${%{name}}'
|
61
60
|
name: Species
|
62
61
|
readonly: true
|
@@ -65,7 +64,7 @@ readonly: true
|
|
65
64
|
| Genus| ${Genus}
|
66
65
|
/ An editable variable in a UX block in a table
|
67
66
|
```ux
|
68
|
-
|
67
|
+
init: false
|
69
68
|
menu_format: '| %{name}| ${%{name}}'
|
70
69
|
name: Family
|
71
70
|
```
|
@@ -9,14 +9,14 @@ menu_with_inherited_lines: true
|
|
9
9
|
```
|
10
10
|
/ This block is not visible. Execute to set a new value, displayed by the block above.
|
11
11
|
```ux :(VAR_has_count)
|
12
|
-
|
12
|
+
init: false
|
13
13
|
echo: $(basename `pwd` | wc -c)
|
14
14
|
force: false
|
15
15
|
name: VAR
|
16
16
|
```
|
17
17
|
/ This block is visible. Execute to set a new value, displayed by the block above.
|
18
18
|
```ux :[IAB_has_count]
|
19
|
-
|
19
|
+
init: false
|
20
20
|
echo: $VAR$VAR
|
21
21
|
name: IAB
|
22
22
|
```
|
@@ -1,21 +1,21 @@
|
|
1
1
|
/ auto-load block, does not execute command to calculate
|
2
2
|
/ click block to calculate
|
3
3
|
```ux :[document_ux0]
|
4
|
-
|
4
|
+
init: ''
|
5
5
|
exec: basename $(pwd)
|
6
6
|
name: ux0
|
7
7
|
```
|
8
8
|
/ auto-load block and execute command to calculate
|
9
9
|
/ click block to recalculate
|
10
10
|
```ux :[document_ux1]
|
11
|
-
|
11
|
+
init: Unknown
|
12
12
|
exec: basename $(pwd)
|
13
13
|
name: ux1
|
14
14
|
```
|
15
15
|
/ auto-load block and execute command to calculate
|
16
16
|
/ click block to recalculate
|
17
17
|
```ux :[document_ux2]
|
18
|
-
|
18
|
+
act: :exec
|
19
19
|
exec: basename $(pwd)
|
20
20
|
name: ux2
|
21
21
|
```
|
@@ -25,7 +25,6 @@ name: ux2
|
|
25
25
|
val () { basename $(pwd) ; }
|
26
26
|
```
|
27
27
|
```ux :[document_ux3] +(bash3)
|
28
|
-
default: :exec
|
29
28
|
exec: val
|
30
29
|
name: ux3
|
31
30
|
```
|
@@ -33,7 +32,6 @@ name: ux3
|
|
33
32
|
/ output of execution is validated/parsed
|
34
33
|
/ parsing is transformed
|
35
34
|
```ux :[document_ux4]
|
36
|
-
default: :exec
|
37
35
|
exec: basename $(pwd)
|
38
36
|
name: ux4
|
39
37
|
transform: "Xform: '%{name}'"
|