markdown_exec 2.0.8.1 → 2.0.8.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bf7b742cc128a608c349ed6ff8b9f921b2e400acb269c4aba3f24d72f43cf007
4
- data.tar.gz: cb0c023316b682f309313167a6900d037df036fa48e451b2dd781d40fed35215
3
+ metadata.gz: 942e4a005f42e2f3c2bd4542ba1b61e666c7379c0a2d81a5427f14ec76590a7d
4
+ data.tar.gz: c38976432cd43684654663876cd6ee5fa35b40339d5217bae00e282c29cd7415
5
5
  SHA512:
6
- metadata.gz: fa191e7433c5dcb5c514894cfdf4bbc3c60b15c416aa7693374eafb40ad39cfeff46bcaa23eed470d8ca67804adc209b4ab6f744d62c8b3f6c4a2f336e43e0f2
7
- data.tar.gz: 260e03667d03854c4d628465d346a1a53029cab8ea1df2614f3fa500df194adc373687e9e096735ed01c41a0bd968f2788a8a60a853c06e9d0ef540409326ab6
6
+ metadata.gz: e02a78e7a564273392203583c1b7d9502647c3379fa0894bf3b2a4b858127cfb8196a493d43e404395762449f267f8e68df48567585aa39d66d804c6c11e2edc
7
+ data.tar.gz: 1bf94ff09d5248dd54853eca88dbc8ebce6ce5c17e9e5110103a2bc91250fa099120a81c7de0f060afdc0d08c607e5fbb7096735aea9ffcb4c7a4ee9bb33220f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ Pass-through arguments after "--" to the script
4
+ M Gemfile.lock
5
+ M bin/tab_completion.sh
6
+ M examples/pass-through.md
7
+ M lib/hash_delegator.rb
8
+ M lib/markdown_exec.rb
9
+ M lib/markdown_exec/version.rb
10
+ M lib/menu.src.yml
11
+ M lib/menu.yml
12
+
3
13
  ## [2.0.8] - 2024-06-05
4
14
 
5
15
  ### Added
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- markdown_exec (2.0.8.1)
4
+ markdown_exec (2.0.8.3)
5
5
  clipboard (~> 1.3.6)
6
6
  open3 (~> 0.1.1)
7
7
  optparse (~> 0.1.1)
@@ -13,7 +13,7 @@ __filedirs_all()
13
13
  }
14
14
 
15
15
  _mde_echo_version() {
16
- echo "2.0.8.1"
16
+ echo "2.0.8.3"
17
17
  }
18
18
 
19
19
  _mde() {
@@ -178,4 +178,4 @@ _mde() {
178
178
 
179
179
  complete -o filenames -o nospace -F _mde mde
180
180
  # _mde_echo_version
181
- # echo "Updated: 2024-06-06 01:08:57 UTC"
181
+ # echo "Updated: 2024-06-15 14:50:18 UTC"
data/examples/linked.md CHANGED
@@ -1,6 +1,7 @@
1
1
  Demonstrate setting variable values interactively for use in generated scripts.
2
2
 
3
3
  ```opts :(document_options)
4
+ menu_with_inherited_lines: true
4
5
  pause_after_script_execution: false
5
6
  user_must_approve: false
6
7
  ```
@@ -40,7 +41,7 @@ vars:
40
41
  ::: Set variable ALPHA in a Vars block
41
42
  For each environment variable named in block,
42
43
  append an inherited line that assigns the variable the specified value.
43
- ```vars :set_ALPHA_to_1_via_vars_block
44
+ ```vars :[set_ALPHA_to_1_via_vars_block]
44
45
  ALPHA: 1
45
46
  ```
46
47
 
@@ -48,7 +49,7 @@ ALPHA: 1
48
49
  For each environment variable in `vars`,
49
50
  append an inherited line that assigns the variable the specified value.
50
51
  Subsequently, run the `display_variable_ALPHA` block.
51
- ```link :set_ALPHA_to_2_via_link_block_and_display
52
+ ```link :[set_ALPHA_to_2_via_link_block_and_display]
52
53
  block: display_variable_ALPHA
53
54
  vars:
54
55
  ALPHA: 2
@@ -59,14 +60,14 @@ Subsequently, run the `display_variable_ALPHA` block.
59
60
  ```bash :(bash_set_to_3)
60
61
  ALPHA=3
61
62
  ```
62
- ```link :set_ALPHA_to_3_via_required_block_and_display +(bash_set_to_3)
63
+ ```link :[set_ALPHA_to_3_via_required_block_and_display] +(bash_set_to_3)
63
64
  block: display_variable_ALPHA
64
65
  ```
65
66
 
66
67
  Evaluate the code in the required block `(bash_eval_set_to_4)` and
67
68
  save (transformed) output into inherited lines.
68
69
  Subsequently, run the `display_variable_ALPHA` block.
69
- ```link :set_ALPHA_to_4_via_evaluated_required_block_and_display +(bash_eval_set_to_4)
70
+ ```link :[set_ALPHA_to_4_via_evaluated_required_block_and_display] +(bash_eval_set_to_4)
70
71
  eval: true
71
72
  next_block: display_variable_ALPHA
72
73
  ```
@@ -1,14 +1,32 @@
1
+ ```opts :(document_options)
2
+ execute_in_own_window: false
3
+ pause_after_script_execution: true
4
+ save_executed_script: true
5
+ saved_script_folder: ../mde_logs
6
+ ```
1
7
  Pass-through arguments after "--" to the executed script.
2
8
 
3
9
  A block can expect arguments to receive all arguments to MDE after "--".
4
10
 
5
- For `mde examples/pass-through.md output_arguments -- 123`,
11
+ For `mde examples/pass-through.md output_arguments -- 1 23`,
6
12
  this block outputs:
7
13
 
8
- ARGS: 123
14
+ ARGS: 1 23
15
+
16
+ ::: Test
17
+ ```bash
18
+ mde examples/pass-through.md output_arguments -- 1 23
19
+ ```
9
20
 
10
- ::: This block will output any arguments after "--" in the command line.
21
+ ::: These options toggle the use of a separate window.
22
+ ```opts
23
+ execute_in_own_window: true
24
+ ```
25
+ ```opts
26
+ execute_in_own_window: false
27
+ ```
11
28
 
29
+ ::: This block will output any command line arguments after "--".
12
30
  ```bash :output_arguments
13
31
  echo "ARGS: $*"
14
32
  ```
@@ -804,7 +804,7 @@ module MarkdownExec
804
804
  system(
805
805
  format(
806
806
  @delegate_object[:execute_command_format],
807
- command_execute_in_own_window_format_arguments
807
+ command_execute_in_own_window_format_arguments(rest: args ? args.join(' ') : '')
808
808
  )
809
809
  )
810
810
 
@@ -832,7 +832,7 @@ module MarkdownExec
832
832
  @fout.fout "Error ENOENT: #{err.inspect}"
833
833
  end
834
834
 
835
- def command_execute_in_own_window_format_arguments(home: Dir.pwd)
835
+ def command_execute_in_own_window_format_arguments(home: Dir.pwd, rest: '')
836
836
  {
837
837
  batch_index: @run_state.batch_index,
838
838
  batch_random: @run_state.batch_random,
@@ -842,6 +842,7 @@ module MarkdownExec
842
842
  home: home,
843
843
  output_filename: File.basename(@delegate_object[:logged_stdout_filespec]),
844
844
  output_filespec: @delegate_object[:logged_stdout_filespec],
845
+ rest: rest,
845
846
  script_filename: @run_state.saved_filespec,
846
847
  script_filespec: File.join(home, @run_state.saved_filespec),
847
848
  started_at: @run_state.started_at.strftime(
@@ -1481,6 +1482,7 @@ module MarkdownExec
1481
1482
  # @param mdoc [YourMDocClass] An instance of the MDoc class.
1482
1483
  #
1483
1484
  def execute_shell_type(selected:, mdoc:, block_source:, link_state: LinkState.new)
1485
+ # binding.irb
1484
1486
  if selected.fetch(:shell, '') == BlockType::LINK
1485
1487
  debounce_reset
1486
1488
  push_link_history_and_trigger_load(link_block_body: selected.fetch(:body, ''),
@@ -1694,7 +1696,6 @@ module MarkdownExec
1694
1696
 
1695
1697
  def inpseq_execute_block(block_name)
1696
1698
  @dml_block_state = block_state_for_name_from_cli(block_name)
1697
-
1698
1699
  dump_and_warn_block_state(selected: @dml_block_state.block)
1699
1700
  @dml_link_state, @dml_menu_default_dname = \
1700
1701
  exec_bash_next_state(
@@ -1760,7 +1761,10 @@ module MarkdownExec
1760
1761
 
1761
1762
  if link_block_data.fetch(LinkKeys::EXEC, false)
1762
1763
  @run_state.files = Hash.new([])
1763
- execute_command_with_streams([cmd])
1764
+ execute_command_with_streams([cmd]) do |_stdin, stdout, stderr, _thread|
1765
+ line = stdout || stderr
1766
+ output_lines.push(line) if line
1767
+ end
1764
1768
 
1765
1769
  ## select output_lines that look like assignment or match other specs
1766
1770
  #
@@ -1827,6 +1831,7 @@ module MarkdownExec
1827
1831
  document_filename: File.basename(@delegate_object[:filename]),
1828
1832
  document_filespec: @delegate_object[:filename],
1829
1833
  home: Dir.pwd,
1834
+ # rest: '',
1830
1835
  started_at: Time.now.utc.strftime(@delegate_object[:execute_command_title_time_format])
1831
1836
  }
1832
1837
  end
@@ -2119,7 +2124,7 @@ module MarkdownExec
2119
2124
  end
2120
2125
 
2121
2126
  def pop_add_current_code_to_head_and_trigger_load(link_state, block_names, code_lines,
2122
- dependencies, selected)
2127
+ dependencies, selected, next_block_name: nil)
2123
2128
  pop = @link_history.pop # updatable
2124
2129
  if pop.document_filename
2125
2130
  next_state = LinkState.new(
@@ -2144,7 +2149,7 @@ module MarkdownExec
2144
2149
  inherited_block_names: ((link_state&.inherited_block_names || []) + block_names).sort.uniq,
2145
2150
  inherited_dependencies: (link_state&.inherited_dependencies || {}).merge(dependencies || {}), ### merge, not replace, key data
2146
2151
  inherited_lines: HashDelegator.code_merge(link_state&.inherited_lines, code_lines),
2147
- next_block_name: '', # not link_block_data[LinkKeys::BLOCK] || ''
2152
+ next_block_name: next_block_name,
2148
2153
  next_document_filename: @delegate_object[:filename], # not next_document_filename
2149
2154
  next_load_file: LoadFile::REUSE # not next_document_filename == @delegate_object[:filename] ? LoadFile::REUSE : LoadFile::LOAD
2150
2155
  )
@@ -2422,7 +2427,7 @@ module MarkdownExec
2422
2427
  end
2423
2428
  end
2424
2429
 
2425
- ## append blocks loaded, apply LinkKeys::EVAL
2430
+ ## append blocks loaded
2426
2431
  #
2427
2432
  if (load_expr = link_block_data.fetch(LinkKeys::LOAD, '')).present?
2428
2433
  load_filespec = load_filespec_from_expression(load_expr)
@@ -2437,10 +2442,11 @@ module MarkdownExec
2437
2442
  end
2438
2443
 
2439
2444
  next_document_filename = write_inherited_lines_to_file(link_state, link_block_data)
2445
+ next_block_name = link_block_data.fetch(LinkKeys::NEXT_BLOCK, nil) || link_block_data.fetch(LinkKeys::BLOCK, nil) || ''
2440
2446
 
2441
2447
  if link_block_data[LinkKeys::RETURN]
2442
2448
  pop_add_current_code_to_head_and_trigger_load(link_state, block_names, code_lines,
2443
- dependencies, selected)
2449
+ dependencies, selected, next_block_name: next_block_name)
2444
2450
 
2445
2451
  else
2446
2452
  link_history_push_and_next(
@@ -2449,8 +2455,7 @@ module MarkdownExec
2449
2455
  inherited_block_names: ((link_state&.inherited_block_names || []) + block_names).sort.uniq,
2450
2456
  inherited_dependencies: (link_state&.inherited_dependencies || {}).merge(dependencies || {}), ### merge, not replace, key data
2451
2457
  inherited_lines: HashDelegator.code_merge(link_state&.inherited_lines, code_lines),
2452
- next_block_name: link_block_data.fetch(LinkKeys::NEXT_BLOCK,
2453
- nil) || link_block_data[LinkKeys::BLOCK] || '',
2458
+ next_block_name: next_block_name,
2454
2459
  next_document_filename: next_document_filename,
2455
2460
  next_load_file: next_document_filename == @delegate_object[:filename] ? LoadFile::REUSE : LoadFile::LOAD
2456
2461
  )
@@ -7,5 +7,5 @@ module MarkdownExec
7
7
  BIN_NAME = 'mde'
8
8
  GEM_NAME = 'markdown_exec'
9
9
  TAP_DEBUG = 'MDE_DEBUG'
10
- VERSION = '2.0.8.1'
10
+ VERSION = '2.0.8.3'
11
11
  end
data/lib/markdown_exec.rb CHANGED
@@ -275,7 +275,7 @@ module MarkdownExec
275
275
  end
276
276
 
277
277
  # return arguments before ARGV_SEP
278
- # arguments after ARGV_SEP are passed to the generatede script
278
+ # arguments after ARGV_SEP are passed to the generated script
279
279
  #
280
280
  def arguments_for_mde(argv = ARGV)
281
281
  case ind = argv.find_index(ARGV_SEP)
data/lib/menu.src.yml CHANGED
@@ -233,8 +233,6 @@
233
233
  :opt_name: exclude_expect_blocks
234
234
  :procname: val_as_bool
235
235
 
236
- # - :default: >
237
- # osascript scripts/applescript/mde.applescript "%{batch_index}" "%{home}" " %{started_at} - %{document_filename} - %{block_name} " "%{script_filespec}" "%{output_filespec}"
238
236
  - :default: >
239
237
  osascript -e '
240
238
  on run argv
@@ -252,7 +250,7 @@
252
250
  write text "o=" & quoted form of output_filespec & ""
253
251
  write text "cd " & quoted form of home & ""
254
252
  write text "echo -ne \"\\033]; " & title & " \\007\""
255
- write text "\"$s\" 2>&1 | tee -a \"$o\""
253
+ write text "\"$s\" %{rest} 2>&1 | tee -a \"$o\""
256
254
  end tell
257
255
  end tell
258
256
  end tell
@@ -261,6 +259,9 @@
261
259
  :env_var: MDE_EXECUTE_COMMAND_FORMAT
262
260
  :opt_name: execute_command_format
263
261
  :procname: val_as_str
262
+ # execute_command_format using a saved script
263
+ # - :default: >
264
+ # osascript scripts/applescript/mde.applescript "%{batch_index}" "%{home}" " %{started_at} - %{document_filename} - %{block_name} " "%{script_filespec}" "%{output_filespec}" %{rest}
264
265
 
265
266
  - :default: "%T"
266
267
  :description: Format for time in window title
@@ -1037,7 +1038,7 @@
1037
1038
 
1038
1039
  - :arg_name: BOOL
1039
1040
  :default: false
1040
- :description: Wheter to save an executed script`
1041
+ :description: Whether to save an executed script
1041
1042
  :env_var: MDE_SAVE_EXECUTED_SCRIPT
1042
1043
  :opt_name: save_executed_script
1043
1044
  :procname: val_as_bool
data/lib/menu.yml CHANGED
@@ -211,7 +211,7 @@
211
211
  write text "o=" & quoted form of output_filespec & ""
212
212
  write text "cd " & quoted form of home & ""
213
213
  write text "echo -ne \"\\033]; " & title & " \\007\""
214
- write text "\"$s\" 2>&1 | tee -a \"$o\""
214
+ write text "\"$s\" %{rest} 2>&1 | tee -a \"$o\""
215
215
  end tell
216
216
  end tell
217
217
  end tell
@@ -884,7 +884,7 @@
884
884
  :procname: val_as_int
885
885
  - :arg_name: BOOL
886
886
  :default: false
887
- :description: Wheter to save an executed script`
887
+ :description: Whether to save an executed script
888
888
  :env_var: MDE_SAVE_EXECUTED_SCRIPT
889
889
  :opt_name: save_executed_script
890
890
  :procname: val_as_bool
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: markdown_exec
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.8.1
4
+ version: 2.0.8.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fareed Stevenson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-06-06 00:00:00.000000000 Z
11
+ date: 2024-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clipboard