markdown_exec 2.8.3 → 2.8.5

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.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +41 -0
  3. data/Gemfile.lock +1 -1
  4. data/Rakefile +33 -23
  5. data/bats/{block-types.bats → block-type-bash.bats} +0 -25
  6. data/bats/block-type-link.bats +9 -0
  7. data/bats/block-type-port.bats +16 -0
  8. data/bats/block-type-ux-allowed.bats +29 -0
  9. data/bats/block-type-ux-auto.bats +1 -1
  10. data/bats/block-type-ux-chained.bats +9 -0
  11. data/bats/block-type-ux-default.bats +8 -0
  12. data/bats/block-type-ux-echo-hash.bats +14 -0
  13. data/bats/block-type-ux-echo.bats +2 -2
  14. data/bats/block-type-ux-exec.bats +1 -1
  15. data/bats/block-type-ux-hidden.bats +9 -0
  16. data/bats/block-type-ux-invalid.bats +8 -0
  17. data/bats/block-type-ux-transform.bats +1 -1
  18. data/bats/indented-block-type-vars.bats +9 -0
  19. data/bats/line-decor-dynamic.bats +1 -1
  20. data/bats/test_helper.bash +9 -2
  21. data/bats/variable-expansion-multiline.bats +8 -0
  22. data/bats/variable-expansion.bats +1 -1
  23. data/docs/dev/block-type-ux-allowed.md +82 -0
  24. data/docs/dev/block-type-ux-auto.md +2 -1
  25. data/docs/dev/block-type-ux-chained.md +21 -0
  26. data/docs/dev/block-type-ux-default.md +42 -0
  27. data/docs/dev/block-type-ux-echo-hash.md +78 -0
  28. data/docs/dev/block-type-ux-echo.md +3 -1
  29. data/docs/dev/block-type-ux-exec.md +1 -0
  30. data/docs/dev/block-type-ux-hidden.md +21 -0
  31. data/docs/dev/block-type-ux-invalid.md +5 -0
  32. data/docs/dev/block-type-ux-require.md +9 -18
  33. data/docs/dev/indented-block-type-vars.md +6 -0
  34. data/docs/dev/line-decor-dynamic.md +2 -1
  35. data/docs/dev/variable-expansion-multiline.md +31 -0
  36. data/lib/ansi_formatter.rb +0 -1
  37. data/lib/ansi_string.rb +1 -1
  38. data/lib/array.rb +0 -1
  39. data/lib/array_util.rb +0 -1
  40. data/lib/block_label.rb +1 -1
  41. data/lib/cached_nested_file_reader.rb +1 -1
  42. data/lib/constants.rb +18 -0
  43. data/lib/directory_searcher.rb +1 -1
  44. data/lib/exceptions.rb +0 -1
  45. data/lib/fcb.rb +52 -9
  46. data/lib/filter.rb +1 -2
  47. data/lib/format_table.rb +1 -0
  48. data/lib/fout.rb +1 -1
  49. data/lib/hash.rb +0 -1
  50. data/lib/hash_delegator.rb +404 -224
  51. data/lib/link_history.rb +17 -17
  52. data/lib/logged_struct.rb +429 -0
  53. data/lib/markdown_exec/version.rb +1 -1
  54. data/lib/markdown_exec.rb +3 -3
  55. data/lib/mdoc.rb +21 -31
  56. data/lib/menu.src.yml +15 -7
  57. data/lib/menu.yml +11 -6
  58. data/lib/namer.rb +3 -6
  59. data/lib/null_result.rb +131 -0
  60. data/lib/object_present.rb +1 -1
  61. data/lib/option_value.rb +1 -1
  62. data/lib/resize_terminal.rb +1 -2
  63. data/lib/saved_assets.rb +1 -1
  64. data/lib/saved_files_matcher.rb +1 -1
  65. data/lib/shell_session.rb +439 -0
  66. data/lib/streams_out.rb +0 -1
  67. data/lib/string_util.rb +11 -1
  68. data/lib/success_result.rb +112 -0
  69. data/lib/text_analyzer.rb +1 -0
  70. data/lib/ww.rb +9 -7
  71. metadata +25 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dfa1920cdbee40306492b597411dff701777c0ac158dc969a02d3ac2db7351b2
4
- data.tar.gz: fe5c8229410f4263b9aa394c99f1d1be61b6a119684ca5c29e8f0a7851d4391a
3
+ metadata.gz: 718a29bb9eed1123158ffab68a01866fcdbc0126736c5305eae92dd661fb7396
4
+ data.tar.gz: 05e374bda6ac5603b13d50a33ef36cffd25d8fccdf43733107d63d19395ee9a5
5
5
  SHA512:
6
- metadata.gz: e2566c1f28e9eb898c490aa9076d762fe76b8f2092a1b6b4a9d37ff889d02bea021cf84fad63c2f9598d7ba17d7a6ac63840d49958d6dfad9f45b57250a4d3b7
7
- data.tar.gz: 44a40a84a65eb477951b6929307837cc8493e70b9fe76b5065bb86e54b2b10f07241de175552132979ddb00b5c8bdce031d64688189b78f5da9f953e74399f4a
6
+ metadata.gz: 18629932f2c6b095329f56ec594eb1016df88b17278ef544f6954f793f054e55c137b8240692392ebba9165c15e0f58b6c1e3883447fa740c90fa1fccb20f351
7
+ data.tar.gz: bc1e0a9ea38227dc83136f2884934ed6dfed93a4c1e73c4c1faa8a6188b2bc7a197062d356f2e3ff5665629e04de46d40904191de9d23af9b6ba31c9f26953d5
data/CHANGELOG.md CHANGED
@@ -1,5 +1,46 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.8.5] - 2025-04-07
4
+
5
+ ### Added
6
+
7
+ - Opts blocks can require other Opts blocks.
8
+ - Options to enable the change of shell expansion patterns.
9
+ - Default ID to each FCB.
10
+ - Convert the value of the 'echo' key to a string.
11
+ - All UX blocks are now loaded automatically.
12
+
13
+ ### Changed
14
+
15
+ - Make 'default' key optional for UX blocks.
16
+ - Use the 'default' option to specify the initial computed value.
17
+
18
+ ## [2.8.4] - 2025-03-24
19
+
20
+ ### Added
21
+
22
+ - 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.
23
+ - A hidden UX block can be required.
24
+ - BATS tests validating an active UX block that requires read-only blocks.
25
+ - UX blocks evaluated automatically load their specified defaults.
26
+ - 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.
27
+ - New `SelectResponse` class tracks user's "Back" choice in interactive menus.
28
+ - `ww` calls now return the last item from the provided array, facilitating prefix usage in statements.
29
+ - Ability to set multiple variables from a single UX block using a dictionary of variable names and evaluated expressions defined in the `echo` parameter.
30
+ - BATS tests covering hidden and invalid UX blocks.
31
+ - Introduced standardized result objects for representing success and failure states, supporting custom payloads for failures.
32
+
33
+ ### Changed
34
+
35
+ - Enabled verbose mode by default for all minitests.
36
+ - Improved whitespace handling in the evaluated output of `echo`.
37
+ - Updated and expanded minitest suite.
38
+ - Update the execution of UX blocks.
39
+ - Aggregated results collected per UX block when processing input from files.
40
+ - Enhanced ANSI sequence tests with more complex formatting scenarios (e.g., bold, italicized, bright-yellow text on a light-yellow background).
41
+ - Standardized script shebangs to consistently execute Ruby minitests via `bundle exec`.
42
+ - Multi-line shell expansions create multiple lines in the menu.
43
+
3
44
  ## [2.8.3] - 2025-02-27
4
45
 
5
46
  ### Added
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- markdown_exec (2.8.3)
4
+ markdown_exec (2.8.5)
5
5
  clipboard (~> 1.3.6)
6
6
  open3 (~> 0.1.1)
7
7
  optparse (~> 0.1.1)
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
- "unset WW; bats #{file}"
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/cached_nested_file_reader.rb',
122
- './lib/collapser.rb',
123
- './lib/directory_searcher.rb',
124
- './lib/evaluate_shell_expressions.rb',
125
- './lib/fcb.rb',
126
- './lib/filter.rb',
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/table_extractor.rb',
141
- './lib/text_analyzer.rb',
142
- './lib/dev/process_template.rb --test'
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
+ }
@@ -4,5 +4,5 @@ load 'test_helper'
4
4
 
5
5
  @test 'Initial values' {
6
6
  spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-ux-auto.md \
7
- 'v1 = _v2 = _v3 = 12_v4 = 21_v5 = markdown_exec_v6 = 31'
7
+ 'v1 = _v2 = _v3 = 12_v4 = 21_v5 = markdown_exec__v6 = 31'
8
8
  }
@@ -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,8 @@
1
+ #!/usr/bin/env bats
2
+
3
+ load 'test_helper'
4
+
5
+ @test 'Initial values' {
6
+ spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-ux-default.md \
7
+ 'v1 = _v2 = 11_v3 = 12_v4 = 21_v5 = markdown_exec__v6 = 31'
8
+ }
@@ -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=1414'
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=markdown_exec_ux3=markdown_exec_ux4=Xform: 'markdown'"
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=markdown_exec_00000000 6d 61 72 6b 64 6f 77 6e 5f 65 78 65 63 0a |markdown_exec.|__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|__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|__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.|'
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
  }
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env bats
2
+
3
+ load 'test_helper'
4
+
5
+ @test 'an indented block with multiple lines' {
6
+ BATS_OUTPUT_FILTER=A
7
+ spec_mde_xansi_dname_doc_blocks_expect docs/dev/indented-block-type-vars.md \
8
+ ' Species: Pongo tapanuliensis_ Genus: Pongo_'
9
+ }
@@ -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
  }
@@ -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
- echo >&2 $EXE "${remaining[@]}"
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,82 @@
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
+ default: ''
22
+ name: FAMILY
23
+ ```
24
+ / automatic block loads default value that is not in allowed list
25
+ ```ux :[document_ux_ORDER]
26
+ allowed:
27
+ - Primates
28
+ - Lophiiformes
29
+ default: Click to select...
30
+ name: ORDER
31
+ ```
32
+ / automatic block loads default value, not in allowed list from echo
33
+ ```ux :[document_ux_CLASS]
34
+ allowed: :echo
35
+ default: Click to select...
36
+ echo: |
37
+ Mammalia
38
+ Actinopterygii
39
+ name: CLASS
40
+ ```
41
+ / executed block presents a menu of the lines in the output of exec
42
+ ```ux :[YEAR_DISCOVERED]
43
+ allowed: :exec
44
+ default: ''
45
+ exec: echo "2017\n2009"
46
+ name: YEAR_DISCOVERED
47
+ ```
48
+ / automatic block presents a menu of the lines in the output of echo
49
+ ```ux :[document_ux_NAME]
50
+ allowed: :echo
51
+ default: :allowed
52
+ echo: |
53
+ Tapanuli Orangutan
54
+ Psychedelic Frogfish
55
+ name: NAME
56
+ ```
57
+ /
58
+ /1. Tapanuli Orangutan
59
+ /
60
+ /* Species: Pongo tapanuliensis
61
+ /* Genus: Pongo
62
+ /* Family: Hominidae
63
+ /* Order: Primates
64
+ /* Class: Mammalia
65
+ /* Phylum: Chordata
66
+ /* Kingdom: Animalia
67
+ /* Domain: Eukaryota
68
+ /* Year: 2017
69
+ /
70
+ /2. Psychedelic Frogfish
71
+ /
72
+ /* Species: Histiophryne psychedelica
73
+ /* Genus: Histiophryne
74
+ /* Family: Antennariidae
75
+ /* Order: Lophiiformes
76
+ /* Class: Actinopterygii
77
+ /* Phylum: Chordata
78
+ /* Kingdom: Animalia
79
+ /* Domain: Eukaryota
80
+ /* Year: 2009
81
+ /
82
+ @import bats-document-configuration.md
@@ -6,7 +6,8 @@ name: v1
6
6
  / name and default
7
7
  / transform and validate options not applied to default
8
8
  ```ux
9
- default: 11
9
+ default: ''
10
+ echo: 11
10
11
  name: v2
11
12
  ```
12
13
  / name and default; auto-load
@@ -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,42 @@
1
+ / v2025-02-08
2
+ / name only
3
+ ```ux
4
+ name: v1
5
+ ```
6
+ / name and default
7
+ / transform and validate options not applied to default
8
+ ```ux
9
+ default: 11
10
+ name: v2
11
+ ```
12
+ / name and default; auto-load
13
+ / prompt option is ignored during auto-load
14
+ ```ux :[document_ux_v3]
15
+ echo: 12
16
+ name: v3
17
+ ```
18
+ / name, default, exec; auto-load static
19
+ ```ux :[document_ux_v4]
20
+ default: 21
21
+ exec: basename $(pwd)
22
+ name: v4
23
+ ```
24
+ / name, default, exec; auto-load executed `basename $(pwd)`
25
+ / allowed is ignored by exec
26
+ ```ux :[document_ux_v5]
27
+ exec: basename $(pwd)
28
+ name: v5
29
+ ```
30
+ / name, default, allowed; auto-load static default
31
+ ```ux :[document_ux_v6]
32
+ allowed:
33
+ - 31
34
+ - 32
35
+ - 33
36
+ name: v6
37
+ ```
38
+ @import bats-document-configuration.md
39
+ ```opts :(document_opts)
40
+ menu_ux_row_format: '%{name} = ${%{name}}'
41
+ ux_auto_load_force_default: true
42
+ ```
@@ -0,0 +1,78 @@
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
+ default: false
14
+ name: DOCUMENTS
15
+ readonly: true
16
+ ```
17
+ / This block displays the third variable in the first block.
18
+ ```ux :[OPERATION]
19
+ default: false
20
+ name: OPERATION
21
+ readonly: true
22
+ ```
23
+ / Multiple UX blocks to set many variables for a specific name.
24
+ ```ux
25
+ default: false
26
+ echo:
27
+ Species: Pongo tapanuliensis
28
+ Genus: Pongo
29
+ Family: Hominidae
30
+ Order: Primates
31
+ Class: Mammalia
32
+ Phylum: Chordata
33
+ Kingdom: Animalia
34
+ Domain: Eukaryota
35
+ Year_Discovered: 2017
36
+ menu_format: 'Load %{name}'
37
+ name: Tapanuli Orangutan
38
+ ```
39
+ ```ux
40
+ default: false
41
+ echo:
42
+ Species: Histiophryne psychedelica
43
+ Genus: Histiophryne
44
+ Family: Antennariidae
45
+ Order: Lophiiformes
46
+ Class: Actinopterygii
47
+ Phylum: Chordata
48
+ Kingdom: Animalia
49
+ Domain: Eukaryota
50
+ Year_Discovered: 2009
51
+ menu_format: 'Load %{name}'
52
+ name: Psychedelic Frogfish
53
+ ```
54
+ / Start a table to format the output of UX blocks
55
+ | Variable| Value
56
+ | -| -
57
+ / A read-only variable in a UX block in a table
58
+ ```ux
59
+ default: false
60
+ menu_format: '| %{name}| ${%{name}}'
61
+ name: Species
62
+ readonly: true
63
+ ```
64
+ / A table row displays one variable in a table
65
+ | Genus| ${Genus}
66
+ / An editable variable in a UX block in a table
67
+ ```ux
68
+ default: false
69
+ menu_format: '| %{name}| ${%{name}}'
70
+ name: Family
71
+ ```
72
+ @import bats-document-configuration.md
73
+ ```opts :(document_opts)
74
+ # menu_ux_row_format: '| %{name}| ${%{name}}'
75
+ screen_width: 64
76
+ table_center: false
77
+ ux_auto_load_force_default: true
78
+ ```
@@ -1,6 +1,5 @@
1
1
  / This automatic block sets VAR and displays the current value in the menu.
2
2
  ```ux :[document_ux_VAR]
3
- default: :echo
4
3
  echo: $(basename `pwd`)
5
4
  name: VAR
6
5
  ```
@@ -10,11 +9,14 @@ menu_with_inherited_lines: true
10
9
  ```
11
10
  / This block is not visible. Execute to set a new value, displayed by the block above.
12
11
  ```ux :(VAR_has_count)
12
+ default: false
13
13
  echo: $(basename `pwd` | wc -c)
14
+ force: false
14
15
  name: VAR
15
16
  ```
16
17
  / This block is visible. Execute to set a new value, displayed by the block above.
17
18
  ```ux :[IAB_has_count]
19
+ default: false
18
20
  echo: $VAR$VAR
19
21
  name: IAB
20
22
  ```
@@ -1,6 +1,7 @@
1
1
  / auto-load block, does not execute command to calculate
2
2
  / click block to calculate
3
3
  ```ux :[document_ux0]
4
+ default: ''
4
5
  exec: basename $(pwd)
5
6
  name: ux0
6
7
  ```