markdown_exec 2.8.3 → 2.8.4
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 +26 -0
- data/Gemfile.lock +1 -1
- data/Rakefile +33 -23
- data/bats/{block-types.bats → block-type-bash.bats} +0 -25
- data/bats/block-type-link.bats +9 -0
- data/bats/block-type-port.bats +16 -0
- data/bats/block-type-ux-allowed.bats +29 -0
- data/bats/block-type-ux-auto.bats +1 -1
- data/bats/block-type-ux-chained.bats +9 -0
- data/bats/block-type-ux-echo-hash.bats +14 -0
- data/bats/block-type-ux-echo.bats +2 -2
- data/bats/block-type-ux-exec.bats +1 -1
- data/bats/block-type-ux-hidden.bats +9 -0
- data/bats/block-type-ux-invalid.bats +8 -0
- data/bats/block-type-ux-transform.bats +1 -1
- data/bats/indented-block-type-vars.bats +9 -0
- data/bats/line-decor-dynamic.bats +1 -1
- data/bats/test_helper.bash +9 -2
- data/bats/variable-expansion-multiline.bats +8 -0
- data/bats/variable-expansion.bats +1 -1
- data/docs/dev/block-type-ux-allowed.md +80 -0
- data/docs/dev/block-type-ux-chained.md +21 -0
- data/docs/dev/block-type-ux-echo-hash.md +72 -0
- data/docs/dev/block-type-ux-hidden.md +21 -0
- data/docs/dev/block-type-ux-invalid.md +5 -0
- data/docs/dev/indented-block-type-vars.md +6 -0
- data/docs/dev/line-decor-dynamic.md +2 -1
- data/docs/dev/variable-expansion-multiline.md +31 -0
- data/lib/ansi_formatter.rb +0 -1
- data/lib/ansi_string.rb +1 -1
- data/lib/array.rb +0 -1
- data/lib/array_util.rb +0 -1
- data/lib/block_label.rb +1 -1
- data/lib/cached_nested_file_reader.rb +1 -1
- data/lib/constants.rb +18 -0
- data/lib/directory_searcher.rb +1 -1
- data/lib/exceptions.rb +0 -1
- data/lib/fcb.rb +36 -5
- data/lib/filter.rb +1 -2
- data/lib/format_table.rb +1 -0
- data/lib/fout.rb +1 -1
- data/lib/hash.rb +0 -1
- data/lib/hash_delegator.rb +310 -162
- data/lib/link_history.rb +17 -17
- data/lib/logged_struct.rb +429 -0
- data/lib/markdown_exec/version.rb +1 -1
- data/lib/markdown_exec.rb +3 -3
- data/lib/mdoc.rb +5 -17
- data/lib/menu.src.yml +3 -1
- data/lib/menu.yml +1 -1
- data/lib/namer.rb +4 -5
- data/lib/null_result.rb +131 -0
- data/lib/object_present.rb +1 -1
- data/lib/option_value.rb +1 -1
- data/lib/resize_terminal.rb +1 -2
- data/lib/saved_assets.rb +1 -1
- data/lib/saved_files_matcher.rb +1 -1
- data/lib/shell_session.rb +439 -0
- data/lib/streams_out.rb +0 -1
- data/lib/string_util.rb +11 -1
- data/lib/success_result.rb +112 -0
- data/lib/text_analyzer.rb +1 -0
- data/lib/ww.rb +9 -7
- metadata +23 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ace0bdaa8d2925a4274a4cfc039fdde5e9aaaf8bfbd761f21e0679417f71062
|
4
|
+
data.tar.gz: 0a9f38be8b322be828fe28cd19441da7a9bb032dd739aaa73ba0526456251503
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0c0c4eea966bad0e29e0957e68049cfee1c61bd730fab880f63ea1501cba153dd1592ef415142a91a9aecd09802cf0bb48eac36607964b97ce372c9b249536f
|
7
|
+
data.tar.gz: d254a22305dd0d57f2048271d40f15d22b6f2473971cc3c398a6479d439fe80255f0dabb7cb94f9df8c21bc6214b2f60b5238c102e3048cbdbd3dd3dd18b693a
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,31 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [2.8.4] - 2025-03-24
|
4
|
+
|
5
|
+
### Added
|
6
|
+
|
7
|
+
- UX block default selection behavior: load as default the first item in `allowed` or the first line in the evaluated output of `echo` or `exec` parameters.
|
8
|
+
- A hidden UX block can be required.
|
9
|
+
- BATS tests validating an active UX block that requires read-only blocks.
|
10
|
+
- UX blocks evaluated automatically load their specified defaults.
|
11
|
+
- During interactive/manual evaluation, UX blocks present a menu of the list in the `allowed` parameter or the lines in the evaluated output of `echo` or `exec` parameters.
|
12
|
+
- New `SelectResponse` class tracks user's "Back" choice in interactive menus.
|
13
|
+
- `ww` calls now return the last item from the provided array, facilitating prefix usage in statements.
|
14
|
+
- Ability to set multiple variables from a single UX block using a dictionary of variable names and evaluated expressions defined in the `echo` parameter.
|
15
|
+
- BATS tests covering hidden and invalid UX blocks.
|
16
|
+
- Introduced standardized result objects for representing success and failure states, supporting custom payloads for failures.
|
17
|
+
|
18
|
+
### Changed
|
19
|
+
|
20
|
+
- Enabled verbose mode by default for all minitests.
|
21
|
+
- Improved whitespace handling in the evaluated output of `echo`.
|
22
|
+
- Updated and expanded minitest suite.
|
23
|
+
- Update the execution of UX blocks.
|
24
|
+
- Aggregated results collected per UX block when processing input from files.
|
25
|
+
- Enhanced ANSI sequence tests with more complex formatting scenarios (e.g., bold, italicized, bright-yellow text on a light-yellow background).
|
26
|
+
- Standardized script shebangs to consistently execute Ruby minitests via `bundle exec`.
|
27
|
+
- Multi-line shell expansions create multiple lines in the menu.
|
28
|
+
|
3
29
|
## [2.8.3] - 2025-02-27
|
4
30
|
|
5
31
|
### Added
|
data/Gemfile.lock
CHANGED
data/Rakefile
CHANGED
@@ -105,7 +105,7 @@ task :bats do
|
|
105
105
|
|
106
106
|
# temporary clear WW to disable debugging
|
107
107
|
# WW pollutes output expected by BATS tests
|
108
|
-
|
108
|
+
%(unset WW; bats #{file})
|
109
109
|
end
|
110
110
|
end
|
111
111
|
|
@@ -117,29 +117,39 @@ end
|
|
117
117
|
desc 'minitest'
|
118
118
|
task :minitest do
|
119
119
|
commands = [
|
120
|
-
'./lib/argument_processor.rb',
|
121
|
-
'./lib/
|
122
|
-
'./lib/
|
123
|
-
'./lib/
|
124
|
-
'./lib/
|
125
|
-
'./lib/
|
126
|
-
'./lib/
|
120
|
+
'./lib/argument_processor.rb --verbose',
|
121
|
+
'./lib/block_label.rb --verbose',
|
122
|
+
'./lib/cached_nested_file_reader.rb --verbose',
|
123
|
+
'./lib/collapser.rb --verbose',
|
124
|
+
'./lib/dev/ansi_codes.rb --verbose',
|
125
|
+
'./lib/dev/append_to_bash_history.rb --verbose',
|
126
|
+
'./lib/dev/generate_transition_codes.rb --verbose',
|
127
|
+
'./lib/dev/hierarchy.rb --verbose',
|
128
|
+
'./lib/dev/process_command.rb --verbose',
|
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
|
+
'./lib/dev/visibility-controller.rb --verbose',
|
133
|
+
'./lib/directory_searcher.rb --verbose',
|
134
|
+
'./lib/evaluate_shell_expressions.rb --verbose',
|
135
|
+
'./lib/fcb.rb --verbose',
|
136
|
+
'./lib/filter.rb --verbose',
|
127
137
|
'./lib/find_files.rb',
|
128
|
-
'./lib/format_table.rb',
|
129
|
-
'./lib/hash_delegator.rb',
|
130
|
-
'./lib/hierarchy_string.rb',
|
131
|
-
'./lib/link_history.rb',
|
132
|
-
'./lib/markdown_exec.rb',
|
133
|
-
'./lib/mdoc.rb',
|
134
|
-
'./lib/object_present.rb',
|
135
|
-
'./lib/option_value.rb',
|
136
|
-
'./lib/regexp.rb',
|
137
|
-
'./lib/resize_terminal.rb',
|
138
|
-
'./lib/saved_assets.rb',
|
139
|
-
'./lib/saved_files_matcher.rb',
|
140
|
-
'./lib/
|
141
|
-
'./lib/
|
142
|
-
'./lib/
|
138
|
+
'./lib/format_table.rb --verbose',
|
139
|
+
'./lib/hash_delegator.rb --verbose',
|
140
|
+
'./lib/hierarchy_string.rb --verbose',
|
141
|
+
'./lib/link_history.rb --verbose',
|
142
|
+
'./lib/markdown_exec.rb --verbose',
|
143
|
+
'./lib/mdoc.rb --verbose',
|
144
|
+
'./lib/object_present.rb --verbose',
|
145
|
+
'./lib/option_value.rb --verbose',
|
146
|
+
'./lib/regexp.rb --verbose',
|
147
|
+
'./lib/resize_terminal.rb --verbose',
|
148
|
+
'./lib/saved_assets.rb --verbose',
|
149
|
+
'./lib/saved_files_matcher.rb --verbose',
|
150
|
+
# './lib/shell_session.rb --verbose',
|
151
|
+
'./lib/table_extractor.rb --verbose',
|
152
|
+
'./lib/text_analyzer.rb --verbose'
|
143
153
|
]
|
144
154
|
|
145
155
|
execute_with_error_handling(commands) do |command|
|
@@ -2,8 +2,6 @@
|
|
2
2
|
|
3
3
|
load 'test_helper'
|
4
4
|
|
5
|
-
# Type: Bash
|
6
|
-
|
7
5
|
@test 'Bash blocks - default' {
|
8
6
|
BATS_OUTPUT_FILTER=A
|
9
7
|
spec_mde_args_expect docs/dev/block-type-bash.md block-with-no-shell-type \
|
@@ -38,26 +36,3 @@ load 'test_helper'
|
|
38
36
|
spec_mde_args_expect docs/dev/block-type-bash.md \[show-shell-version\] \
|
39
37
|
' detected_shell: bash'
|
40
38
|
}
|
41
|
-
|
42
|
-
# Type: Link
|
43
|
-
|
44
|
-
@test 'Link blocks - set variable in link block; call hidden block' {
|
45
|
-
# __Exit is required as last block is a Link type
|
46
|
-
run_mde_specs_md_args_expect_xansi '[VARIABLE1]' __Exit ' VARIABLE1: 1'
|
47
|
-
run_mde_specs_md_args_expect_xansi '[VARIABLE1]' '(echo-VARIABLE1)' ' VARIABLE1: 1 VARIABLE1: 1'
|
48
|
-
}
|
49
|
-
|
50
|
-
# Type: Port
|
51
|
-
|
52
|
-
# includes output from assignment and from shell block
|
53
|
-
@test 'Port block - export variable' {
|
54
|
-
BATS_OUTPUT_FILTER=A
|
55
|
-
spec_mde_args_expect docs/dev/block-type-port.md '[set_vault_1]' show \
|
56
|
-
'VAULT = 1 VAULT: 1'
|
57
|
-
}
|
58
|
-
|
59
|
-
@test 'Port block - export variable - not set' {
|
60
|
-
BATS_OUTPUT_FILTER=A
|
61
|
-
spec_mde_args_expect docs/dev/block-type-port.md VAULT-is-export show \
|
62
|
-
' VAULT: This variable has not been set.'
|
63
|
-
}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
#!/usr/bin/env bats
|
2
|
+
|
3
|
+
load 'test_helper'
|
4
|
+
|
5
|
+
@test 'Link blocks - set variable in link block; call hidden block' {
|
6
|
+
# __Exit is required as last block is a Link type
|
7
|
+
run_mde_specs_md_args_expect_xansi '[VARIABLE1]' __Exit ' VARIABLE1: 1'
|
8
|
+
run_mde_specs_md_args_expect_xansi '[VARIABLE1]' '(echo-VARIABLE1)' ' VARIABLE1: 1 VARIABLE1: 1'
|
9
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env bats
|
2
|
+
|
3
|
+
load 'test_helper'
|
4
|
+
|
5
|
+
# includes output from assignment and from shell block
|
6
|
+
@test 'Port block - export variable' {
|
7
|
+
BATS_OUTPUT_FILTER=A
|
8
|
+
spec_mde_args_expect docs/dev/block-type-port.md '[set_vault_1]' show \
|
9
|
+
'VAULT = 1 VAULT: 1'
|
10
|
+
}
|
11
|
+
|
12
|
+
@test 'Port block - export variable - not set' {
|
13
|
+
BATS_OUTPUT_FILTER=A
|
14
|
+
spec_mde_args_expect docs/dev/block-type-port.md VAULT-is-export show \
|
15
|
+
' VAULT: This variable has not been set.'
|
16
|
+
}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env bats
|
2
|
+
|
3
|
+
load 'test_helper'
|
4
|
+
|
5
|
+
@test 'automatic blocks load defaults - constants or first allowed from output of echo or exec' {
|
6
|
+
spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-ux-allowed.md \
|
7
|
+
'SPECIES=Pongo tapanuliensis_GENUS=Pongo_FAMILY=_ORDER=Click to select..._CLASS=Click to select..._YEAR_DISCOVERED=_NAME=Tapanuli Orangutan'
|
8
|
+
}
|
9
|
+
|
10
|
+
@test 'executing a block loads the first allowed value' {
|
11
|
+
skip 'Unable to test the menu presented'
|
12
|
+
spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-ux-allowed.md \
|
13
|
+
'[FAMILY]' \
|
14
|
+
'SPECIES=Pongo tapanuliensis_GENUS=Pongo_FAMILY=Hominidae_ORDER=Click to select..._CLASS=Click to select..._YEAR_DISCOVERED=_NAME='
|
15
|
+
}
|
16
|
+
|
17
|
+
@test 'executing a block loads the first line in the output of exec' {
|
18
|
+
skip 'Unable to test the menu presented'
|
19
|
+
spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-ux-allowed.md \
|
20
|
+
'[YEAR_DISCOVERED]' \
|
21
|
+
'SPECIES=Pongo tapanuliensis_GENUS=Pongo_FAMILY=_YEAR_DISCOVERED=2017_NAME='
|
22
|
+
}
|
23
|
+
|
24
|
+
@test 'executing a block loads the first line in the output of echo' {
|
25
|
+
skip 'Unable to test the menu presented'
|
26
|
+
spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-ux-allowed.md \
|
27
|
+
'[NAME]' \
|
28
|
+
'SPECIES=Pongo tapanuliensis_GENUS=Pongo_FAMILY=_ORDER=Click to select..._CLASS=Click to select..._YEAR_DISCOVERED=_NAME=Tapanuli Orangutan'
|
29
|
+
}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
#!/usr/bin/env bats
|
2
|
+
|
3
|
+
load 'test_helper'
|
4
|
+
|
5
|
+
@test 'A UX block requires other read-only UX blocks that operate on the computed value.' {
|
6
|
+
spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-ux-chained.md \
|
7
|
+
'[SPECIES]' \
|
8
|
+
'SPECIES=Pongo tapanuliensis_NAME=Pongo tapanuliensis - Pongo'
|
9
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env bats
|
2
|
+
|
3
|
+
load 'test_helper'
|
4
|
+
|
5
|
+
@test 'an automatic block sets multiple variables' {
|
6
|
+
spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-ux-echo-hash.md \
|
7
|
+
'BASENAME=markdown_exec_DOCUMENTS=markdown_OPERATION=exec_Load Tapanuli Orangutan_Load Psychedelic Frogfish_| Variable | Value |_| -------- | ----- |_| Species | |_| Genus | |_| Family | |'
|
8
|
+
}
|
9
|
+
|
10
|
+
@test 'an activated block sets multiple variables' {
|
11
|
+
spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-ux-echo-hash.md \
|
12
|
+
'Load Tapanuli Orangutan' \
|
13
|
+
'BASENAME=markdown_exec_DOCUMENTS=markdown_OPERATION=exec_Load Tapanuli Orangutan_Load Psychedelic Frogfish_| Variable | Value |_| -------- | ----------------------- |_| Species | Pongo tapanuliensis |_| Genus | Pongo |_| Family | Hominidae |'
|
14
|
+
}
|
@@ -13,8 +13,8 @@ load 'test_helper'
|
|
13
13
|
'VAR=markdown_exec_VAR=markdown_exec_IAB='
|
14
14
|
}
|
15
15
|
|
16
|
-
@test 'selected block' {
|
16
|
+
@test 'selected block - output of wc includes whitespace' {
|
17
17
|
spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-ux-echo.md \
|
18
18
|
'(VAR_has_count)' '[IAB_has_count]' \
|
19
|
-
'VAR=14_IAB=
|
19
|
+
'VAR= 14_IAB= 14 14'
|
20
20
|
}
|
@@ -4,5 +4,5 @@ load 'test_helper'
|
|
4
4
|
|
5
5
|
@test 'Output of executed commands as initial value' {
|
6
6
|
spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-ux-exec.md \
|
7
|
-
"ux0=_ux1=Unknown_ux2=
|
7
|
+
"ux0=_ux1=Unknown_ux2=markdown_exec__ux3=markdown_exec__ux4=Xform: 'markdown'"
|
8
8
|
}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
#!/usr/bin/env bats
|
2
|
+
|
3
|
+
load 'test_helper'
|
4
|
+
|
5
|
+
@test 'a UX block requires a shell block and another UX block' {
|
6
|
+
spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-ux-hidden.md \
|
7
|
+
'[SPECIES]' \
|
8
|
+
'SPECIES=Pongo tapanuliensis_NAME=Pongo tapanuliensis - Pongo'
|
9
|
+
}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
#!/usr/bin/env bats
|
2
|
+
|
3
|
+
load 'test_helper'
|
4
|
+
|
5
|
+
@test 'automatic block is invalid YAML' {
|
6
|
+
spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-ux-invalid.md \
|
7
|
+
'_Error: HashDelegator../docs/dev/block-type-ux-invalid.md_vmlpd_bfnf_b_3 - --- !ruby/object:NullResult_message: Invalid YAML_data: invalid_ -- -- '
|
8
|
+
}
|
@@ -4,5 +4,5 @@ load 'test_helper'
|
|
4
4
|
|
5
5
|
@test 'Transformed output of executed commands' {
|
6
6
|
spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-ux-transform.md \
|
7
|
-
'_Execution output has a trailing newline._Var0=
|
7
|
+
'_Execution output has a trailing newline._Var0=markdown_exec__00000000 6d 61 72 6b 64 6f 77 6e 5f 65 78 65 63 0a |markdown_exec.|_0000000e__With validate and transform, output has no newline._Var1=markdown_exec_00000000 6d 61 72 6b 64 6f 77 6e 5f 65 78 65 63 |markdown_exec|_0000000d__With transform :chomp, output has no newline._Var2=markdown_exec_00000000 6d 61 72 6b 64 6f 77 6e 5f 65 78 65 63 |markdown_exec|_0000000d__With transform :upcase, output is in upper case w/ newline._Var3=MARKDOWN_EXEC__00000000 4d 41 52 4b 44 4f 57 4e 5f 45 58 45 43 0a |MARKDOWN_EXEC.|_0000000e'
|
8
8
|
}
|
@@ -4,5 +4,5 @@ load 'test_helper'
|
|
4
4
|
|
5
5
|
@test 'Line decor, dynamic - new pattern, line_decor_pre, ansi' {
|
6
6
|
spec_mde_dname_doc_blocks_expect docs/dev/line-decor-dynamic.md \
|
7
|
-
$'\e[38;2;200;200;33m\e[48;2;60;60;32mSpecies\e[0m'
|
7
|
+
$'\e[1m\e[3m\e[38;2;200;200;33m\e[48;2;60;60;32mSpecies\e[22;23;0m'
|
8
8
|
}
|
data/bats/test_helper.bash
CHANGED
@@ -27,6 +27,9 @@ echo_hexdump_expected_output_filter () {
|
|
27
27
|
echo_hexdump "$(remove_ansi_escape_sequences "$output")"
|
28
28
|
echo "- expected"
|
29
29
|
echo_hexdump "$expected"
|
30
|
+
|
31
|
+
# print the byte offset of the first difference
|
32
|
+
#diff <(remove_ansi_escape_sequences "$output") <(echo -n "$expected") | grep "^[0-9a-f]{8} " | cut -c 1-8
|
30
33
|
fi
|
31
34
|
}
|
32
35
|
|
@@ -178,9 +181,13 @@ spec_mde_args_grep_filter_expect () {
|
|
178
181
|
SL="${BATS_SLEEP}"
|
179
182
|
|
180
183
|
if [[ -z $SL ]]; then
|
181
|
-
|
184
|
+
debug_args=()
|
185
|
+
for arg in "${remaining[@]}"; do
|
186
|
+
escaped_arg=$(printf '%q' "$arg")
|
187
|
+
debug_args+=("$escaped_arg")
|
188
|
+
done
|
189
|
+
echo >&2 $EXE "${debug_args[@]}"
|
182
190
|
|
183
|
-
# Pass the exact arguments including empty and space-containing ones
|
184
191
|
run $EXE "${remaining[@]}"
|
185
192
|
else
|
186
193
|
bash -c "
|
@@ -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/variable-expansion-multiline.md \
|
7
|
+
'Genus2 = Pongo_Pongo_UX block:_Genus2=Pongo_Pongo_Command substitution:_Genus2 hex: 00000000 50 6f 6e 67 6f 0a 50 6f 6e 67 6f |Pongo.Pongo|_0000000b_Command substitution:_Genus2 text: Pongo_Pongo_Command substitution:_Gemfile_Gemfile.lock_Variable expansion:_Genus2 text: Pongo_Pongo'
|
8
|
+
}
|
@@ -4,7 +4,7 @@ load 'test_helper'
|
|
4
4
|
|
5
5
|
@test 'Variable expansion - default' {
|
6
6
|
spec_mde_xansi_dname_doc_blocks_expect docs/dev/variable-expansion.md \
|
7
|
-
'EVIDENCE_SOURCE is:_SOURCE is:_SOURCE is:_| SOURCE |_| ------ |__name_with_${SOURCE}_in_name_load: file_.sh_SOURCES'
|
7
|
+
'EVIDENCE_SOURCE is:_SOURCE is:_SOURCE is: _| SOURCE |_| ------ |__name_with_${SOURCE}_in_name_load: file_.sh_SOURCES'
|
8
8
|
}
|
9
9
|
|
10
10
|
@test 'Variable expansion - LINK_LOAD_SOURCE' {
|
@@ -0,0 +1,80 @@
|
|
1
|
+
/ automatic block loads first allowed
|
2
|
+
```ux :[document_ux_SPECIES]
|
3
|
+
allowed:
|
4
|
+
- Pongo tapanuliensis
|
5
|
+
- Histiophryne psychedelica
|
6
|
+
default: :allowed
|
7
|
+
name: SPECIES
|
8
|
+
```
|
9
|
+
/ automatic block loads first line in output of exec
|
10
|
+
```ux :[document_ux_GENUS]
|
11
|
+
allowed: :exec
|
12
|
+
default: :allowed
|
13
|
+
exec: echo "Pongo\nHistiophryne psychedelica"
|
14
|
+
name: GENUS
|
15
|
+
```
|
16
|
+
/ executed block presents a menu of the allowed list
|
17
|
+
```ux :[FAMILY]
|
18
|
+
allowed:
|
19
|
+
- Hominidae
|
20
|
+
- Antennariidae
|
21
|
+
name: FAMILY
|
22
|
+
```
|
23
|
+
/ automatic block loads default value that is not in allowed list
|
24
|
+
```ux :[document_ux_ORDER]
|
25
|
+
allowed:
|
26
|
+
- Primates
|
27
|
+
- Lophiiformes
|
28
|
+
default: Click to select...
|
29
|
+
name: ORDER
|
30
|
+
```
|
31
|
+
/ automatic block loads default value, not in allowed list from echo
|
32
|
+
```ux :[document_ux_CLASS]
|
33
|
+
allowed: :echo
|
34
|
+
default: Click to select...
|
35
|
+
echo: |
|
36
|
+
Mammalia
|
37
|
+
Actinopterygii
|
38
|
+
name: CLASS
|
39
|
+
```
|
40
|
+
/ executed block presents a menu of the lines in the output of exec
|
41
|
+
```ux :[YEAR_DISCOVERED]
|
42
|
+
allowed: :exec
|
43
|
+
exec: echo "2017\n2009"
|
44
|
+
name: YEAR_DISCOVERED
|
45
|
+
```
|
46
|
+
/ automatic block presents a menu of the lines in the output of echo
|
47
|
+
```ux :[document_ux_NAME]
|
48
|
+
allowed: :echo
|
49
|
+
default: :allowed
|
50
|
+
echo: |
|
51
|
+
Tapanuli Orangutan
|
52
|
+
Psychedelic Frogfish
|
53
|
+
name: NAME
|
54
|
+
```
|
55
|
+
/
|
56
|
+
/1. Tapanuli Orangutan
|
57
|
+
/
|
58
|
+
/* Species: Pongo tapanuliensis
|
59
|
+
/* Genus: Pongo
|
60
|
+
/* Family: Hominidae
|
61
|
+
/* Order: Primates
|
62
|
+
/* Class: Mammalia
|
63
|
+
/* Phylum: Chordata
|
64
|
+
/* Kingdom: Animalia
|
65
|
+
/* Domain: Eukaryota
|
66
|
+
/* Year: 2017
|
67
|
+
/
|
68
|
+
/2. Psychedelic Frogfish
|
69
|
+
/
|
70
|
+
/* Species: Histiophryne psychedelica
|
71
|
+
/* Genus: Histiophryne
|
72
|
+
/* Family: Antennariidae
|
73
|
+
/* Order: Lophiiformes
|
74
|
+
/* Class: Actinopterygii
|
75
|
+
/* Phylum: Chordata
|
76
|
+
/* Kingdom: Animalia
|
77
|
+
/* Domain: Eukaryota
|
78
|
+
/* Year: 2009
|
79
|
+
/
|
80
|
+
@import bats-document-configuration.md
|
@@ -0,0 +1,21 @@
|
|
1
|
+
/ a UX block that requires a shell block and another UX block
|
2
|
+
``` :(shell)
|
3
|
+
ENTITY='Pongo tapanuliensis,Pongo'
|
4
|
+
```
|
5
|
+
```ux :[SPECIES] +(shell) +(GENUS)
|
6
|
+
echo: "${ENTITY%%,*}"
|
7
|
+
name: SPECIES
|
8
|
+
```
|
9
|
+
/ required ux block requires another
|
10
|
+
```ux :(GENUS) +[NAME]
|
11
|
+
echo: "${ENTITY##*,}"
|
12
|
+
name: GENUS
|
13
|
+
readonly: true
|
14
|
+
```
|
15
|
+
/ executed in context of prior ux blocks, uses their values
|
16
|
+
```ux :[NAME]
|
17
|
+
echo: "$SPECIES - $GENUS"
|
18
|
+
name: NAME
|
19
|
+
readonly: true
|
20
|
+
```
|
21
|
+
@import bats-document-configuration.md
|
@@ -0,0 +1,72 @@
|
|
1
|
+
/ This automatic block sets multiple variables and displays the first variable.
|
2
|
+
```ux :[document_ux_BASENAME]
|
3
|
+
default: :echo
|
4
|
+
echo:
|
5
|
+
BASENAME: "$(basename `pwd`)"
|
6
|
+
DOCUMENTS: "${BASENAME%%_*}"
|
7
|
+
OPERATION: "${BASENAME##*_}"
|
8
|
+
name: BASENAME
|
9
|
+
readonly: true
|
10
|
+
```
|
11
|
+
/ This block displays the second variable in the first block.
|
12
|
+
```ux :[DOCUMENTS]
|
13
|
+
name: DOCUMENTS
|
14
|
+
readonly: true
|
15
|
+
```
|
16
|
+
/ This block displays the third variable in the first block.
|
17
|
+
```ux :[OPERATION]
|
18
|
+
name: OPERATION
|
19
|
+
readonly: true
|
20
|
+
```
|
21
|
+
/ Multiple UX blocks to set many variables for a specific name.
|
22
|
+
```ux
|
23
|
+
echo:
|
24
|
+
Species: Pongo tapanuliensis
|
25
|
+
Genus: Pongo
|
26
|
+
Family: Hominidae
|
27
|
+
Order: Primates
|
28
|
+
Class: Mammalia
|
29
|
+
Phylum: Chordata
|
30
|
+
Kingdom: Animalia
|
31
|
+
Domain: Eukaryota
|
32
|
+
Year_Discovered: 2017
|
33
|
+
menu_format: 'Load %{name}'
|
34
|
+
name: Tapanuli Orangutan
|
35
|
+
```
|
36
|
+
```ux
|
37
|
+
echo:
|
38
|
+
Species: Histiophryne psychedelica
|
39
|
+
Genus: Histiophryne
|
40
|
+
Family: Antennariidae
|
41
|
+
Order: Lophiiformes
|
42
|
+
Class: Actinopterygii
|
43
|
+
Phylum: Chordata
|
44
|
+
Kingdom: Animalia
|
45
|
+
Domain: Eukaryota
|
46
|
+
Year_Discovered: 2009
|
47
|
+
menu_format: 'Load %{name}'
|
48
|
+
name: Psychedelic Frogfish
|
49
|
+
```
|
50
|
+
/ Start a table to format the output of UX blocks
|
51
|
+
| Variable| Value
|
52
|
+
| -| -
|
53
|
+
/ A read-only variable in a UX block in a table
|
54
|
+
```ux
|
55
|
+
menu_format: '| %{name}| ${%{name}}'
|
56
|
+
name: Species
|
57
|
+
readonly: true
|
58
|
+
```
|
59
|
+
/ A table row displays one variable in a table
|
60
|
+
| Genus| ${Genus}
|
61
|
+
/ An editable variable in a UX block in a table
|
62
|
+
```ux
|
63
|
+
menu_format: '| %{name}| ${%{name}}'
|
64
|
+
name: Family
|
65
|
+
```
|
66
|
+
@import bats-document-configuration.md
|
67
|
+
```opts :(document_opts)
|
68
|
+
# menu_ux_row_format: '| %{name}| ${%{name}}'
|
69
|
+
screen_width: 64
|
70
|
+
table_center: false
|
71
|
+
ux_auto_load_force_default: true
|
72
|
+
```
|
@@ -0,0 +1,21 @@
|
|
1
|
+
/ a UX block requires a shell block and another UX block
|
2
|
+
``` :(shell)
|
3
|
+
ENTITY='Pongo tapanuliensis,Pongo'
|
4
|
+
```
|
5
|
+
```ux :[SPECIES] +(shell) +(GENUS)
|
6
|
+
echo: "${ENTITY%%,*}"
|
7
|
+
name: SPECIES
|
8
|
+
```
|
9
|
+
/ required ux block requires another
|
10
|
+
```ux :(GENUS) +[NAME]
|
11
|
+
echo: "${ENTITY##*,}"
|
12
|
+
name: GENUS
|
13
|
+
readonly: true
|
14
|
+
```
|
15
|
+
/ executed in context of prior ux blocks, uses their values
|
16
|
+
```ux :[NAME]
|
17
|
+
echo: "$SPECIES - $GENUS"
|
18
|
+
name: NAME
|
19
|
+
readonly: true
|
20
|
+
```
|
21
|
+
@import bats-document-configuration.md
|
@@ -4,6 +4,7 @@
|
|
4
4
|
@import bats-document-configuration.md
|
5
5
|
```opts :(document_opts)
|
6
6
|
line_decor_pre:
|
7
|
-
|
7
|
+
# bold italicized bright yellow text on light yellow background
|
8
|
+
- :color_method: :ansi_1__3__38_2_200_200_33__48_2_60_60_32__22_23_0
|
8
9
|
:pattern: '%([^_]{0,64})%'
|
9
10
|
```
|
@@ -0,0 +1,31 @@
|
|
1
|
+
/ assign a multiline string
|
2
|
+
```vars :(document_vars)
|
3
|
+
Genus2: |
|
4
|
+
Pongo
|
5
|
+
Pongo
|
6
|
+
```
|
7
|
+
/
|
8
|
+
/ display the variable
|
9
|
+
__UX block__:
|
10
|
+
```ux
|
11
|
+
name: Genus2
|
12
|
+
readonly: true
|
13
|
+
```
|
14
|
+
/
|
15
|
+
/ Confirm the string contains a newline `0a`
|
16
|
+
__Command substitution__:
|
17
|
+
Genus2 hex: $(printf "$Genus2" | hexdump -C)
|
18
|
+
/
|
19
|
+
/ output with substitution
|
20
|
+
__Command substitution__:
|
21
|
+
Genus2 text: $(printf "$Genus2")
|
22
|
+
/
|
23
|
+
/ output with substitution
|
24
|
+
__Command substitution__:
|
25
|
+
$(ls -1 G*)
|
26
|
+
/
|
27
|
+
/ output with expansion
|
28
|
+
__Variable expansion__:
|
29
|
+
Genus2 text: ${Genus2}
|
30
|
+
/
|
31
|
+
@import bats-document-configuration.md
|
data/lib/ansi_formatter.rb
CHANGED
data/lib/ansi_string.rb
CHANGED
@@ -20,7 +20,7 @@ class AnsiString < String
|
|
20
20
|
segments[0..-2].each do |segment|
|
21
21
|
codes += "\033[#{segment.split('_').join(';')}m"
|
22
22
|
end
|
23
|
-
codes +=
|
23
|
+
codes += to_s
|
24
24
|
codes += "\033[#{segments.last.split('_').join(';')}m"
|
25
25
|
self.class.new(codes)
|
26
26
|
when /^fg_bg_rgb_/
|
data/lib/array.rb
CHANGED
data/lib/array_util.rb
CHANGED