markdown_exec 3.0.5 → 3.0.7
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 +10 -0
- data/Gemfile.lock +1 -1
- data/bats/block-type-ux-act-init.bats +17 -0
- data/bats/block-type-ux-echo.bats +1 -2
- data/bats/block-type-ux-sources.bats +1 -1
- data/bats/block-type-ux-transform.bats +1 -1
- data/bats/import-conflict.bats +11 -0
- data/bats/import-duplicates.bats +53 -0
- data/bats/variable-expansion-multiline.bats +1 -1
- data/bin/bmde +4 -3
- data/docs/dev/block-type-ux-act-init.md +187 -0
- data/docs/dev/block-type-ux-auto.md +0 -1
- data/docs/dev/block-type-ux-default.md +2 -2
- data/docs/dev/block-type-ux-echo.md +1 -1
- data/docs/dev/block-type-ux-exec.md +0 -1
- data/docs/dev/block-type-ux-sources.md +1 -1
- data/docs/dev/block-type-ux-transform.md +5 -4
- data/docs/dev/command-substitution.md +1 -0
- data/docs/dev/import-conflict-0.md +12 -0
- data/docs/dev/import-conflict-1.md +7 -0
- data/docs/dev/import-duplicates-0.md +17 -0
- data/docs/dev/import-duplicates-1.md +13 -0
- data/docs/dev/load_code.md +1 -0
- data/docs/dev/no-active-elements.md +1 -0
- data/docs/dev/variable-expansion-multiline.md +4 -1
- data/docs/ux-blocks-examples.md +120 -0
- data/docs/ux-blocks-init-act.md +100 -0
- data/lib/command_result.rb +12 -0
- data/lib/command_result_alternatives.rb +233 -0
- data/lib/env_interface.rb +57 -0
- data/lib/hash_delegator.rb +186 -116
- data/lib/markdown_exec/version.rb +1 -1
- data/lib/resize_terminal.rb +11 -5
- data/lib/ww.rb +4 -1
- metadata +14 -2
data/lib/hash_delegator.rb
CHANGED
@@ -44,6 +44,7 @@ require_relative 'string_util'
|
|
44
44
|
require_relative 'table_extractor'
|
45
45
|
require_relative 'text_analyzer'
|
46
46
|
require_relative 'value_or_exception'
|
47
|
+
require_relative 'env_interface'
|
47
48
|
|
48
49
|
$pd = false unless defined?($pd)
|
49
50
|
$table_cell_truncate = true
|
@@ -96,10 +97,6 @@ module HashDelegatorSelf
|
|
96
97
|
blocks.select { |item| item.send(msg) == value }
|
97
98
|
end
|
98
99
|
|
99
|
-
def code_merge(*bodies)
|
100
|
-
merge_lists(*bodies)
|
101
|
-
end
|
102
|
-
|
103
100
|
def count_matches_in_lines(lines, regex)
|
104
101
|
lines.count { |line| line.to_s.match(regex) }
|
105
102
|
end
|
@@ -157,6 +154,14 @@ module HashDelegatorSelf
|
|
157
154
|
)
|
158
155
|
end
|
159
156
|
|
157
|
+
# Takes multiple arrays as arguments, flattens them into a single array, and removes nil values.
|
158
|
+
# @param args [Array<Array>] Variable number of arrays to be processed
|
159
|
+
# @return [Array] A single flattened array with nil values removed, or an empty array if the result is empty
|
160
|
+
def flatten_and_compact_arrays(*args)
|
161
|
+
merged = args.compact.flatten
|
162
|
+
merged.empty? ? [] : merged
|
163
|
+
end
|
164
|
+
|
160
165
|
# Indents all lines in a given string with a specified indentation string.
|
161
166
|
# @param body [String] A multi-line string to be indented.
|
162
167
|
# @param indent [String] The string used for indentation
|
@@ -177,13 +182,6 @@ module HashDelegatorSelf
|
|
177
182
|
((lines || []) + ['']).join("\n")
|
178
183
|
end
|
179
184
|
|
180
|
-
def merge_lists(*args)
|
181
|
-
# Filters out nil values, flattens the arrays, and ensures an
|
182
|
-
# empty list is returned if no valid lists are provided.
|
183
|
-
merged = args.compact.flatten
|
184
|
-
merged.empty? ? [] : merged
|
185
|
-
end
|
186
|
-
|
187
185
|
def next_link_state(
|
188
186
|
block_name_from_cli:, was_using_cli:, block_state:, block_name: nil
|
189
187
|
)
|
@@ -501,10 +499,6 @@ class BashCommentFormatter
|
|
501
499
|
end
|
502
500
|
formatted.join("\n")
|
503
501
|
end
|
504
|
-
# # fit oname in single bash comment
|
505
|
-
# def oname_for_bash_comment(oname)
|
506
|
-
# oname.gsub("\n", ' ~ ').gsub(/ +/, ' ')
|
507
|
-
# end
|
508
502
|
end
|
509
503
|
|
510
504
|
class StringWrapper
|
@@ -1177,28 +1171,15 @@ module MarkdownExec
|
|
1177
1171
|
transform_export_value(name_force[:text], export)
|
1178
1172
|
else
|
1179
1173
|
name_force[:text]
|
1174
|
+
|
1180
1175
|
end
|
1181
|
-
|
1176
|
+
EnvInterface.set(name_force[:name], transformed)
|
1177
|
+
|
1182
1178
|
code_line_safe_assign(
|
1183
1179
|
name_force[:name], transformed, force: name_force[:force]
|
1184
1180
|
)
|
1185
1181
|
end
|
1186
1182
|
required_lines.concat(command_result_w_e_t_nl.new_lines)
|
1187
|
-
|
1188
|
-
if SelectResponse.continue?(command_result_w_e_t_nl.stdout)
|
1189
|
-
if command_result_w_e_t_nl.transformable
|
1190
|
-
command_result_w_e_t_nl.stdout = transform_export_value(
|
1191
|
-
command_result_w_e_t_nl.stdout, export
|
1192
|
-
)
|
1193
|
-
end
|
1194
|
-
|
1195
|
-
if command_result_w_e_t_nl.exportable
|
1196
|
-
ENV[export.name] = command_result_w_e_t_nl.stdout.to_s
|
1197
|
-
required_lines.push code_line_safe_assign(
|
1198
|
-
export.name, command_result_w_e_t_nl.stdout, force: force
|
1199
|
-
)
|
1200
|
-
end
|
1201
|
-
end
|
1202
1183
|
ret_command_result = command_result_w_e_t_nl
|
1203
1184
|
else
|
1204
1185
|
raise "Invalid data type: #{data.inspect}"
|
@@ -1206,6 +1187,13 @@ module MarkdownExec
|
|
1206
1187
|
end
|
1207
1188
|
|
1208
1189
|
ret_command_result || CommandResult.new(stdout: required_lines)
|
1190
|
+
rescue StandardError
|
1191
|
+
ww $@, $!
|
1192
|
+
HashDelegator.error_handler('code_from_ux_block_to_set_environment_variables')
|
1193
|
+
end
|
1194
|
+
|
1195
|
+
def env_set(name, value)
|
1196
|
+
EnvInterface.set(name, value)
|
1209
1197
|
end
|
1210
1198
|
|
1211
1199
|
# sets ENV
|
@@ -1214,7 +1202,7 @@ module MarkdownExec
|
|
1214
1202
|
case data = YAML.load(selected.body.join("\n"))
|
1215
1203
|
when Hash
|
1216
1204
|
data.each do |key, value|
|
1217
|
-
|
1205
|
+
EnvInterface.set(key, value.to_s)
|
1218
1206
|
code_lines.push "#{key}=#{Shellwords.escape(value)}"
|
1219
1207
|
|
1220
1208
|
next unless @delegate_object[:menu_vars_set_format].present?
|
@@ -1908,7 +1896,7 @@ module MarkdownExec
|
|
1908
1896
|
before_mtime = temp_file.mtime
|
1909
1897
|
|
1910
1898
|
# Open the temporary file in the default editor
|
1911
|
-
system("#{
|
1899
|
+
system("#{EnvInterface.get('EDITOR', default: 'vi')} #{temp_file.path}")
|
1912
1900
|
|
1913
1901
|
# Capture the exit status of the editor
|
1914
1902
|
editor_exit_status = $?.exitstatus
|
@@ -2051,13 +2039,16 @@ module MarkdownExec
|
|
2051
2039
|
next_state_append_code(
|
2052
2040
|
selected,
|
2053
2041
|
link_state,
|
2054
|
-
command_result_w_e_t_nl.failure? ? [] : command_result_w_e_t_nl.
|
2042
|
+
command_result_w_e_t_nl.failure? ? [] : command_result_w_e_t_nl.new_lines
|
2055
2043
|
)
|
2056
2044
|
|
2057
2045
|
elsif selected.type == BlockType::VARS
|
2058
2046
|
debounce_reset
|
2059
|
-
next_state_append_code(
|
2060
|
-
|
2047
|
+
next_state_append_code(
|
2048
|
+
selected,
|
2049
|
+
link_state,
|
2050
|
+
code_from_vars_block_to_set_environment_variables(selected)
|
2051
|
+
)
|
2061
2052
|
|
2062
2053
|
elsif COLLAPSIBLE_TYPES.include?(selected.type)
|
2063
2054
|
debounce_reset
|
@@ -2182,7 +2173,7 @@ module MarkdownExec
|
|
2182
2173
|
if link_block_data[LinkKeys::VARS]
|
2183
2174
|
code_lines.push BashCommentFormatter.format_comment(selected.pub_name)
|
2184
2175
|
(link_block_data[LinkKeys::VARS] || []).each do |(key, value)|
|
2185
|
-
|
2176
|
+
EnvInterface.set(key, value.to_s)
|
2186
2177
|
code_lines.push(assign_key_value_in_bash(key, value))
|
2187
2178
|
end
|
2188
2179
|
end
|
@@ -2237,7 +2228,7 @@ module MarkdownExec
|
|
2237
2228
|
((link_state&.inherited_block_names || []) + block_names).sort.uniq,
|
2238
2229
|
inherited_dependencies:
|
2239
2230
|
(link_state&.inherited_dependencies || {}).merge(dependencies || {}), ### merge, not replace, key data
|
2240
|
-
inherited_lines: HashDelegator.
|
2231
|
+
inherited_lines: HashDelegator.flatten_and_compact_arrays(
|
2241
2232
|
link_state&.inherited_lines, code_lines
|
2242
2233
|
),
|
2243
2234
|
keep_code: link_state&.keep_code,
|
@@ -2345,15 +2336,15 @@ module MarkdownExec
|
|
2345
2336
|
|
2346
2337
|
if selected[:type] == BlockType::OPTS
|
2347
2338
|
# body of blocks is returned as a list of lines to be read an YAML
|
2348
|
-
HashDelegator.
|
2339
|
+
HashDelegator.flatten_and_compact_arrays(required[:blocks].map(&:body).flatten(1))
|
2349
2340
|
else
|
2350
2341
|
code_lines = if selected.type == BlockType::VARS
|
2351
2342
|
code_from_vars_block_to_set_environment_variables(selected)
|
2352
2343
|
else
|
2353
2344
|
[]
|
2354
2345
|
end
|
2355
|
-
HashDelegator.
|
2356
|
-
|
2346
|
+
HashDelegator.flatten_and_compact_arrays(link_state&.inherited_lines,
|
2347
|
+
required[:code] + code_lines)
|
2357
2348
|
end
|
2358
2349
|
end
|
2359
2350
|
|
@@ -2575,6 +2566,7 @@ module MarkdownExec
|
|
2575
2566
|
link_state: link_state,
|
2576
2567
|
pattern: options_command_substitution_regexp
|
2577
2568
|
)
|
2569
|
+
# no return
|
2578
2570
|
end
|
2579
2571
|
|
2580
2572
|
def expand_variable_references!(
|
@@ -2604,31 +2596,37 @@ module MarkdownExec
|
|
2604
2596
|
return if replacements == EvaluateShellExpression::StatusFail
|
2605
2597
|
|
2606
2598
|
expand_blocks_with_replacements(blocks, replacements)
|
2599
|
+
# no return
|
2607
2600
|
end
|
2608
2601
|
|
2609
2602
|
def export_echo_with_code(
|
2610
|
-
bash_script_lines, export, force:, silent:
|
2603
|
+
bash_script_lines, export, force:, silent:, string: nil
|
2611
2604
|
)
|
2612
2605
|
exportable = true
|
2613
2606
|
command_result = nil
|
2614
2607
|
new_lines = []
|
2615
|
-
|
2608
|
+
export_string = string.nil? ? export.echo : string
|
2609
|
+
case export_string
|
2616
2610
|
when String, Integer, Float, TrueClass, FalseClass
|
2617
|
-
command_result = output_from_adhoc_bash_script_file(
|
2611
|
+
command_result, = output_from_adhoc_bash_script_file(
|
2618
2612
|
join_array_of_arrays(
|
2619
2613
|
bash_script_lines,
|
2620
|
-
%(printf '%s' "#{
|
2614
|
+
%(printf '%s' "#{export_string}")
|
2621
2615
|
)
|
2622
2616
|
)
|
2623
2617
|
if command_result.exit_status == EXIT_STATUS_REQUIRED_EMPTY
|
2624
2618
|
exportable = false
|
2625
2619
|
command_result.warning = warning_required_empty(export) unless silent
|
2620
|
+
else
|
2621
|
+
EnvInterface.set(export.name, command_result.stdout.to_s)
|
2622
|
+
new_lines << { name: export.name, force: force,
|
2623
|
+
text: command_result.stdout }
|
2626
2624
|
end
|
2627
2625
|
|
2628
2626
|
when Hash
|
2629
2627
|
# each item in the hash is a variable name and value
|
2630
|
-
|
2631
|
-
command_result = output_from_adhoc_bash_script_file(
|
2628
|
+
export_string.each do |name, expression|
|
2629
|
+
command_result, = output_from_adhoc_bash_script_file(
|
2632
2630
|
join_array_of_arrays(
|
2633
2631
|
bash_script_lines,
|
2634
2632
|
%(printf '%s' "#{expression}")
|
@@ -2637,14 +2635,11 @@ module MarkdownExec
|
|
2637
2635
|
if command_result.exit_status == EXIT_STATUS_REQUIRED_EMPTY
|
2638
2636
|
command_result.warning = warning_required_empty(export) unless silent
|
2639
2637
|
else
|
2640
|
-
|
2638
|
+
EnvInterface.set(name, command_result.stdout.to_s)
|
2641
2639
|
new_lines << { name: name, force: force,
|
2642
2640
|
text: command_result.stdout }
|
2643
2641
|
end
|
2644
2642
|
end
|
2645
|
-
|
2646
|
-
# individual items have been exported, none remain
|
2647
|
-
exportable = false
|
2648
2643
|
end
|
2649
2644
|
|
2650
2645
|
[command_result, exportable, new_lines]
|
@@ -2755,7 +2750,7 @@ module MarkdownExec
|
|
2755
2750
|
# Format expression using environment variables and run state
|
2756
2751
|
def format_expression(expr)
|
2757
2752
|
data = link_load_format_data
|
2758
|
-
|
2753
|
+
EnvInterface.each { |key, value| data[key.to_sym] = value }
|
2759
2754
|
format(expr, data)
|
2760
2755
|
end
|
2761
2756
|
|
@@ -3002,14 +2997,14 @@ module MarkdownExec
|
|
3002
2997
|
# convert single items to arrays
|
3003
2998
|
def join_array_of_arrays(*args)
|
3004
2999
|
args.map do |item|
|
3005
|
-
item.is_a?(Array) ? item : [item]
|
3000
|
+
item.nil? ? nil : (item.is_a?(Array) ? item : [item])
|
3006
3001
|
end.compact.flatten(1)
|
3007
3002
|
end
|
3008
3003
|
|
3009
3004
|
def link_block_data_eval(link_state, code_lines, selected, link_block_data,
|
3010
3005
|
block_source:, shell:)
|
3011
|
-
all_code = HashDelegator.
|
3012
|
-
|
3006
|
+
all_code = HashDelegator.flatten_and_compact_arrays(link_state&.inherited_lines,
|
3007
|
+
code_lines)
|
3013
3008
|
output_lines = []
|
3014
3009
|
|
3015
3010
|
Tempfile.open do |file|
|
@@ -3304,8 +3299,11 @@ module MarkdownExec
|
|
3304
3299
|
[block_name_from_cli, now_using_cli]
|
3305
3300
|
end
|
3306
3301
|
|
3307
|
-
def mdoc_and_blocks_from_nested_files(source_id: nil)
|
3308
|
-
blocks_results = blocks_from_nested_files(
|
3302
|
+
def mdoc_and_blocks_from_nested_files(source_id: nil, link_state: nil)
|
3303
|
+
blocks_results = blocks_from_nested_files(
|
3304
|
+
link_state: link_state,
|
3305
|
+
source_id: source_id
|
3306
|
+
)
|
3309
3307
|
|
3310
3308
|
blocks_results.results.select do |_id, result|
|
3311
3309
|
result.failure?
|
@@ -3328,7 +3326,10 @@ module MarkdownExec
|
|
3328
3326
|
#
|
3329
3327
|
reload_blocks = false
|
3330
3328
|
|
3331
|
-
all_blocks, mdoc = mdoc_and_blocks_from_nested_files(
|
3329
|
+
all_blocks, mdoc = mdoc_and_blocks_from_nested_files(
|
3330
|
+
link_state: link_state,
|
3331
|
+
source_id: source_id
|
3332
|
+
)
|
3332
3333
|
if load_auto_opts_block(all_blocks, mdoc: mdoc)
|
3333
3334
|
reload_blocks = true
|
3334
3335
|
end
|
@@ -3344,8 +3345,8 @@ module MarkdownExec
|
|
3344
3345
|
# load document ux block
|
3345
3346
|
#
|
3346
3347
|
if (code_lines = code_from_automatic_ux_blocks(all_blocks, mdoc))
|
3347
|
-
new_code = HashDelegator.
|
3348
|
-
|
3348
|
+
new_code = HashDelegator.flatten_and_compact_arrays(link_state.inherited_lines,
|
3349
|
+
code_lines)
|
3349
3350
|
next_state_set_code(nil, link_state, new_code)
|
3350
3351
|
link_state.inherited_lines = new_code
|
3351
3352
|
reload_blocks = true
|
@@ -3354,15 +3355,18 @@ module MarkdownExec
|
|
3354
3355
|
# load document vars block
|
3355
3356
|
#
|
3356
3357
|
if (code_lines = load_auto_vars_block(all_blocks))
|
3357
|
-
new_code = HashDelegator.
|
3358
|
-
|
3358
|
+
new_code = HashDelegator.flatten_and_compact_arrays(link_state.inherited_lines,
|
3359
|
+
code_lines)
|
3359
3360
|
next_state_set_code(nil, link_state, new_code)
|
3360
3361
|
link_state.inherited_lines = new_code
|
3361
3362
|
reload_blocks = true
|
3362
3363
|
end
|
3363
3364
|
|
3364
3365
|
if reload_blocks
|
3365
|
-
all_blocks, mdoc = mdoc_and_blocks_from_nested_files(
|
3366
|
+
all_blocks, mdoc = mdoc_and_blocks_from_nested_files(
|
3367
|
+
link_state: link_state,
|
3368
|
+
source_id: source_id
|
3369
|
+
)
|
3366
3370
|
end
|
3367
3371
|
|
3368
3372
|
# filter by name, collapsed
|
@@ -3531,7 +3535,7 @@ module MarkdownExec
|
|
3531
3535
|
next_state_set_code(
|
3532
3536
|
selected,
|
3533
3537
|
link_state,
|
3534
|
-
HashDelegator.
|
3538
|
+
HashDelegator.flatten_and_compact_arrays(
|
3535
3539
|
link_state&.inherited_lines,
|
3536
3540
|
code_lines.is_a?(Array) ? code_lines : [] # no code for :ux_exec_prohibited
|
3537
3541
|
)
|
@@ -3548,7 +3552,7 @@ module MarkdownExec
|
|
3548
3552
|
((link_state&.inherited_block_names || []) + block_names).sort.uniq,
|
3549
3553
|
inherited_dependencies:
|
3550
3554
|
(link_state&.inherited_dependencies || {}).merge(dependencies || {}), ### merge, not replace, key data
|
3551
|
-
inherited_lines: HashDelegator.
|
3555
|
+
inherited_lines: HashDelegator.flatten_and_compact_arrays(code_lines),
|
3552
3556
|
keep_code: link_state&.keep_code,
|
3553
3557
|
next_block_name: '',
|
3554
3558
|
next_document_filename: @delegate_object[:filename],
|
@@ -3592,7 +3596,10 @@ module MarkdownExec
|
|
3592
3596
|
}
|
3593
3597
|
end
|
3594
3598
|
|
3595
|
-
def output_from_adhoc_bash_script_file(
|
3599
|
+
def output_from_adhoc_bash_script_file(
|
3600
|
+
bash_script_lines,
|
3601
|
+
export = nil
|
3602
|
+
)
|
3596
3603
|
Tempfile.create('script_exec') do |temp_file|
|
3597
3604
|
temp_file.write(
|
3598
3605
|
HashDelegator.join_code_lines(
|
@@ -3612,7 +3619,32 @@ module MarkdownExec
|
|
3612
3619
|
|
3613
3620
|
output = `#{shell} #{temp_file.path}`
|
3614
3621
|
|
3615
|
-
|
3622
|
+
exportable = export ? export.exportable : false
|
3623
|
+
new_lines = []
|
3624
|
+
if export
|
3625
|
+
new_lines << "#{export.name}="
|
3626
|
+
export_value = output
|
3627
|
+
### transform?
|
3628
|
+
|
3629
|
+
command_result, exportable, new_lines = export_echo_with_code(
|
3630
|
+
["#{export.name}=#{Shellwords.escape(export_value)}"],
|
3631
|
+
export,
|
3632
|
+
force: force,
|
3633
|
+
silent: silent,
|
3634
|
+
string: export_value
|
3635
|
+
)
|
3636
|
+
else
|
3637
|
+
command_result = CommandResult.new(
|
3638
|
+
stdout: output,
|
3639
|
+
exit_status: $?.exitstatus
|
3640
|
+
)
|
3641
|
+
end
|
3642
|
+
|
3643
|
+
[
|
3644
|
+
command_result,
|
3645
|
+
exportable,
|
3646
|
+
new_lines
|
3647
|
+
]
|
3616
3648
|
end
|
3617
3649
|
rescue StandardError => err
|
3618
3650
|
warn "Error executing script: #{err.message}"
|
@@ -3653,7 +3685,8 @@ module MarkdownExec
|
|
3653
3685
|
inherited_dependencies:
|
3654
3686
|
dependencies.merge(pop.inherited_dependencies || {}), ### merge, not replace, key data
|
3655
3687
|
inherited_lines:
|
3656
|
-
HashDelegator.
|
3688
|
+
HashDelegator.flatten_and_compact_arrays(pop.inherited_lines,
|
3689
|
+
code_lines)
|
3657
3690
|
)
|
3658
3691
|
@link_history.push(next_state)
|
3659
3692
|
|
@@ -3670,7 +3703,9 @@ module MarkdownExec
|
|
3670
3703
|
inherited_dependencies:
|
3671
3704
|
(link_state&.inherited_dependencies || {}).merge(dependencies || {}), ### merge, not replace, key data
|
3672
3705
|
inherited_lines:
|
3673
|
-
HashDelegator.
|
3706
|
+
HashDelegator.flatten_and_compact_arrays(
|
3707
|
+
link_state&.inherited_lines, code_lines
|
3708
|
+
),
|
3674
3709
|
keep_code: link_state&.keep_code,
|
3675
3710
|
next_block_name: next_block_name,
|
3676
3711
|
next_document_filename: @delegate_object[:filename], # not next_document_filename
|
@@ -4624,16 +4659,21 @@ module MarkdownExec
|
|
4624
4659
|
def ux_block_export_activated(
|
4625
4660
|
bash_script_lines, export, exit_prompt
|
4626
4661
|
)
|
4662
|
+
command_result = nil
|
4627
4663
|
exportable = true
|
4628
|
-
|
4664
|
+
force = true
|
4629
4665
|
new_lines = []
|
4630
|
-
|
4666
|
+
silent = false
|
4667
|
+
transformable = true
|
4631
4668
|
|
4632
4669
|
case FCB.act_source(export)
|
4633
4670
|
when false, UxActSource::FALSE
|
4634
|
-
|
4671
|
+
# read-only
|
4672
|
+
command_result = CommandResult.new
|
4673
|
+
exportable = false
|
4674
|
+
transformable = false
|
4635
4675
|
|
4636
|
-
when
|
4676
|
+
when :allow, UxActSource::ALLOW
|
4637
4677
|
raise unless export.allow.present?
|
4638
4678
|
|
4639
4679
|
case export.allow
|
@@ -4641,9 +4681,10 @@ module MarkdownExec
|
|
4641
4681
|
command_result, exportable, new_lines = export_echo_with_code(
|
4642
4682
|
bash_script_lines,
|
4643
4683
|
export,
|
4644
|
-
force:
|
4645
|
-
silent:
|
4684
|
+
force: force,
|
4685
|
+
silent: silent
|
4646
4686
|
)
|
4687
|
+
|
4647
4688
|
if command_result.failure?
|
4648
4689
|
command_result
|
4649
4690
|
else
|
@@ -4652,8 +4693,8 @@ module MarkdownExec
|
|
4652
4693
|
)
|
4653
4694
|
end
|
4654
4695
|
|
4655
|
-
when
|
4656
|
-
command_result = output_from_adhoc_bash_script_file(
|
4696
|
+
when :exec, UxActSource::EXEC
|
4697
|
+
command_result, = output_from_adhoc_bash_script_file(
|
4657
4698
|
join_array_of_arrays(bash_script_lines, export.exec)
|
4658
4699
|
)
|
4659
4700
|
|
@@ -4668,22 +4709,26 @@ module MarkdownExec
|
|
4668
4709
|
end
|
4669
4710
|
|
4670
4711
|
else
|
4671
|
-
|
4672
|
-
|
4712
|
+
export_init = menu_from_list_with_back(export.allow)
|
4713
|
+
command_result, exportable, new_lines = export_echo_with_code(
|
4714
|
+
["#{export.name}=#{Shellwords.escape(export_init)}"],
|
4715
|
+
export,
|
4716
|
+
force: force,
|
4717
|
+
silent: silent,
|
4718
|
+
string: export_init
|
4673
4719
|
)
|
4720
|
+
|
4674
4721
|
end
|
4675
4722
|
|
4676
|
-
when
|
4723
|
+
when :echo, UxActSource::ECHO
|
4677
4724
|
command_result, exportable, new_lines = export_echo_with_code(
|
4678
4725
|
bash_script_lines,
|
4679
4726
|
export,
|
4680
|
-
force:
|
4681
|
-
silent:
|
4727
|
+
force: force,
|
4728
|
+
silent: silent
|
4682
4729
|
)
|
4683
4730
|
|
4684
|
-
|
4685
|
-
|
4686
|
-
when ':edit', UxActSource::EDIT
|
4731
|
+
when :edit, UxActSource::EDIT
|
4687
4732
|
output = nil
|
4688
4733
|
begin
|
4689
4734
|
loop do
|
@@ -4703,13 +4748,11 @@ module MarkdownExec
|
|
4703
4748
|
|
4704
4749
|
command_result = CommandResult.new(stdout: output)
|
4705
4750
|
|
4706
|
-
when
|
4707
|
-
command_result = output_from_adhoc_bash_script_file(
|
4751
|
+
when :exec, UxActSource::EXEC
|
4752
|
+
command_result, = output_from_adhoc_bash_script_file(
|
4708
4753
|
join_array_of_arrays(bash_script_lines, export.exec)
|
4709
4754
|
)
|
4710
4755
|
|
4711
|
-
command_result
|
4712
|
-
|
4713
4756
|
else
|
4714
4757
|
transformable = false
|
4715
4758
|
command_result = CommandResult.new(stdout: export.default.to_s)
|
@@ -4718,7 +4761,7 @@ module MarkdownExec
|
|
4718
4761
|
# add message for required variables
|
4719
4762
|
if command_result.exit_status == EXIT_STATUS_REQUIRED_EMPTY
|
4720
4763
|
command_result.warning = warning_required_empty(export)
|
4721
|
-
|
4764
|
+
warn command_result.warning unless silent
|
4722
4765
|
end
|
4723
4766
|
|
4724
4767
|
command_result.exportable = exportable
|
@@ -4727,12 +4770,15 @@ module MarkdownExec
|
|
4727
4770
|
command_result
|
4728
4771
|
end
|
4729
4772
|
|
4730
|
-
def ux_block_export_automatic(
|
4731
|
-
|
4773
|
+
def ux_block_export_automatic(
|
4774
|
+
bash_script_lines, export
|
4775
|
+
)
|
4776
|
+
command_result = nil
|
4732
4777
|
exportable = true
|
4778
|
+
force = false
|
4733
4779
|
new_lines = []
|
4734
|
-
command_result = nil
|
4735
4780
|
silent = true
|
4781
|
+
transformable = true
|
4736
4782
|
|
4737
4783
|
case FCB.init_source(export)
|
4738
4784
|
when false, UxActSource::FALSE
|
@@ -4740,57 +4786,85 @@ module MarkdownExec
|
|
4740
4786
|
transformable = false
|
4741
4787
|
command_result = CommandResult.new
|
4742
4788
|
|
4743
|
-
when
|
4789
|
+
when :allow, UxActSource::ALLOW
|
4744
4790
|
raise unless export.allow.present?
|
4745
4791
|
|
4746
4792
|
case export.allow
|
4747
4793
|
when :echo, ExportValueSource::ECHO
|
4794
|
+
cr_echo, = output_from_adhoc_bash_script_file(
|
4795
|
+
join_array_of_arrays(
|
4796
|
+
bash_script_lines,
|
4797
|
+
%(printf '%s' "#{export.echo}")
|
4798
|
+
)
|
4799
|
+
)
|
4800
|
+
export_init = cr_echo.stdout.split("\n").first
|
4748
4801
|
command_result, exportable, new_lines = export_echo_with_code(
|
4749
|
-
|
4802
|
+
["#{export.name}=#{Shellwords.escape(export_init)}"],
|
4750
4803
|
export,
|
4751
|
-
force:
|
4752
|
-
silent: silent
|
4804
|
+
force: force,
|
4805
|
+
silent: silent,
|
4806
|
+
string: export_init
|
4753
4807
|
)
|
4754
|
-
unless command_result.failure?
|
4755
|
-
command_result.stdout = (exportable && command_result.stdout.split("\n").first) || ''
|
4756
|
-
end
|
4757
4808
|
|
4758
4809
|
when :exec, ExportValueSource::EXEC
|
4759
|
-
|
4810
|
+
# extract first line from 'exec' output
|
4811
|
+
command_result, = output_from_adhoc_bash_script_file(
|
4760
4812
|
join_array_of_arrays(bash_script_lines, export.exec)
|
4761
4813
|
)
|
4762
4814
|
unless command_result.failure?
|
4763
|
-
|
4815
|
+
export_init = command_result.stdout.split("\n").first
|
4816
|
+
command_result, exportable, new_lines = export_echo_with_code(
|
4817
|
+
["#{export.name}=#{Shellwords.escape(export_init)}"],
|
4818
|
+
export,
|
4819
|
+
force: force,
|
4820
|
+
silent: silent,
|
4821
|
+
string: export_init
|
4822
|
+
)
|
4764
4823
|
end
|
4765
4824
|
|
4766
4825
|
else
|
4767
|
-
#
|
4768
|
-
|
4826
|
+
# first item from 'allow' list
|
4827
|
+
export_init = export.allow.first
|
4828
|
+
command_result, exportable, new_lines = export_echo_with_code(
|
4829
|
+
["#{export.name}=#{Shellwords.escape(export_init)}"],
|
4830
|
+
export,
|
4831
|
+
force: force,
|
4832
|
+
silent: silent,
|
4833
|
+
string: export_init
|
4834
|
+
)
|
4835
|
+
|
4769
4836
|
end
|
4770
4837
|
|
4771
|
-
when
|
4838
|
+
when :default, UxActSource::DEFAULT
|
4772
4839
|
transformable = false
|
4773
4840
|
command_result = CommandResult.new(stdout: export.default.to_s)
|
4774
4841
|
|
4775
|
-
when
|
4842
|
+
when :echo, UxActSource::ECHO
|
4776
4843
|
raise unless export.echo.present?
|
4777
4844
|
|
4778
4845
|
command_result, exportable, new_lines = export_echo_with_code(
|
4779
4846
|
bash_script_lines,
|
4780
4847
|
export,
|
4781
|
-
force:
|
4848
|
+
force: force,
|
4782
4849
|
silent: silent
|
4783
4850
|
)
|
4784
|
-
|
4785
|
-
when ':exec', UxActSource::EXEC
|
4851
|
+
when :exec, UxActSource::EXEC
|
4786
4852
|
raise unless export.exec.present?
|
4787
4853
|
|
4788
|
-
command_result = output_from_adhoc_bash_script_file(
|
4789
|
-
join_array_of_arrays(bash_script_lines, export.exec)
|
4854
|
+
command_result, exportable, new_lines = output_from_adhoc_bash_script_file(
|
4855
|
+
join_array_of_arrays(bash_script_lines, export.exec),
|
4856
|
+
export
|
4790
4857
|
)
|
4791
4858
|
|
4792
4859
|
else
|
4793
|
-
|
4860
|
+
export_init = export.init.to_s
|
4861
|
+
command_result, exportable, new_lines = export_echo_with_code(
|
4862
|
+
["#{export.name}=#{Shellwords.escape(export_init)}"],
|
4863
|
+
export,
|
4864
|
+
force: force,
|
4865
|
+
silent: silent,
|
4866
|
+
string: export_init
|
4867
|
+
)
|
4794
4868
|
# raise "Unknown FCB.init_source(export) #{FCB.init_source(export)}"
|
4795
4869
|
end
|
4796
4870
|
|
@@ -5206,9 +5280,6 @@ module MarkdownExec
|
|
5206
5280
|
)
|
5207
5281
|
end
|
5208
5282
|
# rubocop:enable Style/GuardClause
|
5209
|
-
|
5210
|
-
# # reflect new menu items
|
5211
|
-
# @dml_mdoc = MDoc.new(@dml_menu_blocks)
|
5212
5283
|
end
|
5213
5284
|
|
5214
5285
|
def vux_navigate_back_for_ls
|
@@ -5245,7 +5316,6 @@ module MarkdownExec
|
|
5245
5316
|
mdoc_menu_and_blocks_from_nested_files(
|
5246
5317
|
@dml_link_state, source_id: source_id
|
5247
5318
|
)
|
5248
|
-
|
5249
5319
|
dump_delobj(@dml_blocks_in_file, @dml_menu_blocks, @dml_link_state)
|
5250
5320
|
end
|
5251
5321
|
|