markdown_exec 1.8.8 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -1
- data/CHANGELOG.md +20 -0
- data/Gemfile +3 -2
- data/Gemfile.lock +2 -8
- data/bin/tab_completion.sh +11 -3
- data/examples/colors.md +41 -19
- data/examples/document_options.md +8 -0
- data/examples/duplicate_block.md +5 -8
- data/examples/import0.md +3 -5
- data/examples/import1.md +1 -1
- data/examples/include.md +16 -10
- data/examples/indent.md +2 -0
- data/examples/index.md +68 -0
- data/examples/linked.md +100 -39
- data/examples/llm.md +54 -0
- data/lib/constants.rb +6 -1
- data/lib/find_files.rb +1 -2
- data/lib/hash_delegator.rb +529 -211
- data/lib/input_sequencer.rb +229 -0
- data/lib/link_history.rb +11 -5
- data/lib/markdown_exec/version.rb +1 -1
- data/lib/markdown_exec.rb +4 -6
- data/lib/mdoc.rb +7 -7
- data/lib/menu.src.yml +60 -25
- data/lib/menu.yml +53 -20
- metadata +6 -3
- data/examples/infile_config.md +0 -10
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
#!/usr/bin/env bundle exec ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
# encoding=utf-8
|
|
5
|
+
|
|
6
|
+
require_relative 'dev/instance_method_wrapper' # for ImwUx
|
|
7
|
+
require_relative 'env'
|
|
8
|
+
require_relative 'link_history'
|
|
9
|
+
|
|
10
|
+
# InputSequencer manages the sequence of menu interactions and block executions based on user input.
|
|
11
|
+
class InputSequencer
|
|
12
|
+
# extend ImwUx # This makes imw_indent available as a class method
|
|
13
|
+
# include ImwUx # This makes imw_indent available as a class method
|
|
14
|
+
|
|
15
|
+
# self.prepend InstanceMethodWrapper # traps initialize as well
|
|
16
|
+
attr_reader :document_filename, :current_block, :block_queue
|
|
17
|
+
|
|
18
|
+
def initialize(document_filename, initial_blocks = nil)
|
|
19
|
+
@document_filename = document_filename
|
|
20
|
+
@current_block = nil
|
|
21
|
+
@block_queue = initial_blocks
|
|
22
|
+
@debug = Env::env_bool('INPUT_SEQUENCER_DEBUG', default: false) ### false e
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Merges the current menu state with the next, prioritizing the next state's values.
|
|
26
|
+
def self.merge_link_state(current, next_state)
|
|
27
|
+
MarkdownExec::LinkState.new(
|
|
28
|
+
block_name: next_state.block_name,
|
|
29
|
+
display_menu: next_state.display_menu.nil? ? current.display_menu : next_state.display_menu,
|
|
30
|
+
document_filename: next_state.document_filename || current.document_filename,
|
|
31
|
+
inherited_block_names: next_state.inherited_block_names,
|
|
32
|
+
inherited_dependencies: next_state.inherited_dependencies,
|
|
33
|
+
inherited_lines: next_state.inherited_lines,
|
|
34
|
+
prior_block_was_link: next_state.prior_block_was_link.nil? ? current.prior_block_was_link : next_state.prior_block_was_link
|
|
35
|
+
)
|
|
36
|
+
rescue
|
|
37
|
+
binding.irb
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Generates the next menu state based on provided attributes.
|
|
41
|
+
|
|
42
|
+
def self.next_link_state(block_name: nil, display_menu: nil, document_filename: nil, prior_block_was_link: false)
|
|
43
|
+
MarkdownExec::LinkState.new(
|
|
44
|
+
block_name: block_name,
|
|
45
|
+
display_menu: display_menu,
|
|
46
|
+
document_filename: document_filename,
|
|
47
|
+
prior_block_was_link: prior_block_was_link
|
|
48
|
+
)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Orchestrates the flow of menu states and user interactions.
|
|
52
|
+
def run_yield(sym, *args, &block)
|
|
53
|
+
block.call sym, *args
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def bq_is_empty?
|
|
57
|
+
!@block_queue || @block_queue.empty?
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# Orchestrates the flow of menu states and user interactions.
|
|
61
|
+
def run(&block)
|
|
62
|
+
now_menu = InputSequencer.next_link_state(
|
|
63
|
+
display_menu: bq_is_empty?,
|
|
64
|
+
document_filename: @document_filename,
|
|
65
|
+
prior_block_was_link: false # true bypass_exit when last block was a link (from cli)
|
|
66
|
+
)
|
|
67
|
+
exit_when_bq_empty = !bq_is_empty? # true when running blocks from cli; unless "stay" is used
|
|
68
|
+
loop do
|
|
69
|
+
break if run_yield(:parse_document, now_menu.document_filename, &block) == :break
|
|
70
|
+
|
|
71
|
+
pp [__LINE__, 'exit_when_bq_empty', exit_when_bq_empty, '@block_queue', @block_queue, 'now_menu', now_menu] if @debug
|
|
72
|
+
# self.imw_ins now_menu, 'now_menu'
|
|
73
|
+
|
|
74
|
+
break if exit_when_bq_empty && bq_is_empty? && !now_menu.prior_block_was_link
|
|
75
|
+
|
|
76
|
+
if now_menu.display_menu
|
|
77
|
+
exit_when_bq_empty = false
|
|
78
|
+
|
|
79
|
+
run_yield :display_menu, &block
|
|
80
|
+
|
|
81
|
+
choice = run_yield :user_choice, &block
|
|
82
|
+
|
|
83
|
+
break if run_yield(:exit?, choice&.downcase, &block) # Exit loop and method to terminate the app
|
|
84
|
+
|
|
85
|
+
next_state = run_yield :execute_block, choice, &block
|
|
86
|
+
# imw_ins next_state, 'next_state'
|
|
87
|
+
pp [__LINE__, 'next_state', next_state] if @debug
|
|
88
|
+
return :break if next_state == :break
|
|
89
|
+
|
|
90
|
+
next_menu = next_state
|
|
91
|
+
|
|
92
|
+
else
|
|
93
|
+
if now_menu.block_name && !now_menu.block_name.empty?
|
|
94
|
+
block_name = now_menu.block_name
|
|
95
|
+
else
|
|
96
|
+
break if bq_is_empty? # Exit loop if no more blocks to process
|
|
97
|
+
|
|
98
|
+
block_name = @block_queue.shift
|
|
99
|
+
end
|
|
100
|
+
# self.imw_ins block_name, 'block_name'
|
|
101
|
+
pp [__LINE__, 'block_name', block_name] if @debug
|
|
102
|
+
|
|
103
|
+
next_menu = if block_name == '.'
|
|
104
|
+
exit_when_bq_empty = false
|
|
105
|
+
InputSequencer.next_link_state(display_menu: true)
|
|
106
|
+
else
|
|
107
|
+
state = run_yield :execute_block, block_name, &block
|
|
108
|
+
state.display_menu = bq_is_empty?
|
|
109
|
+
state
|
|
110
|
+
end
|
|
111
|
+
pp [__LINE__, 'next_menu', next_menu] if @debug
|
|
112
|
+
next_menu
|
|
113
|
+
# imw_ins next_menu, 'next_menu'
|
|
114
|
+
end
|
|
115
|
+
now_menu = InputSequencer.merge_link_state(now_menu, next_menu)
|
|
116
|
+
end
|
|
117
|
+
rescue
|
|
118
|
+
binding.irb
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
return if __FILE__ != $PROGRAM_NAME
|
|
123
|
+
|
|
124
|
+
$doc1 = {
|
|
125
|
+
'b1' => 'Content of bash1',
|
|
126
|
+
'b2' => 'Content of bash2',
|
|
127
|
+
'b3' => 'Content of bash3',
|
|
128
|
+
'l1' => { 'block_name' => 'b1', 'document_filename' => 'd1' },
|
|
129
|
+
'l2' => { 'block_name' => 'b2', 'document_filename' => 'd2' },
|
|
130
|
+
'l3' => { 'block_name' => 'b3' }
|
|
131
|
+
}.freeze
|
|
132
|
+
$stay = '.' # keep menu open (from command line)
|
|
133
|
+
$texit = 'x'
|
|
134
|
+
|
|
135
|
+
class MDE
|
|
136
|
+
# extend ImwUx # This makes imw_indent available as a class method
|
|
137
|
+
# include ImwUx # This makes imw_indent available as a class method
|
|
138
|
+
|
|
139
|
+
def initialize(document_filename, initial_blocks = [])
|
|
140
|
+
@inpseq = InputSequencer.new(document_filename, initial_blocks)
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
def do_run
|
|
144
|
+
@inpseq.run do |msg, data|
|
|
145
|
+
case msg
|
|
146
|
+
when :parse_document # once for each menu
|
|
147
|
+
# self.imw_ins data, '@ - parse document'
|
|
148
|
+
parse_document(data)
|
|
149
|
+
when :display_menu
|
|
150
|
+
puts "? - Select a block to execute (or type #{$texit} to exit):"
|
|
151
|
+
puts "doc: #{@document_filename}"
|
|
152
|
+
display_menu
|
|
153
|
+
when :user_choice
|
|
154
|
+
$stdin.gets.chomp
|
|
155
|
+
when :execute_block
|
|
156
|
+
# self.imw_ins data, "! - Executing block"
|
|
157
|
+
execute_block(data)
|
|
158
|
+
when :exit?
|
|
159
|
+
data == $texit
|
|
160
|
+
when :stay?
|
|
161
|
+
data == $stay
|
|
162
|
+
else
|
|
163
|
+
raise "Invalid message: #{msg}"
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
private
|
|
169
|
+
|
|
170
|
+
def display_menu
|
|
171
|
+
@blocks.each_key { |block| puts block }
|
|
172
|
+
puts $texit
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
def execute_block(block_name)
|
|
176
|
+
content = @blocks[block_name]
|
|
177
|
+
if content
|
|
178
|
+
puts content
|
|
179
|
+
if block_name.start_with?('l')
|
|
180
|
+
interpret_link_block(content)
|
|
181
|
+
else
|
|
182
|
+
InputSequencer.next_link_state
|
|
183
|
+
end
|
|
184
|
+
else
|
|
185
|
+
puts "! - Block not found: #{block_name}"
|
|
186
|
+
InputSequencer.next_link_state
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
def interpret_link_block(content)
|
|
191
|
+
# Stub: Interpret a "Link" block, extracting directives for the next action
|
|
192
|
+
# In a real implementation, this would parse the content for next block or document
|
|
193
|
+
puts "! - Interpreting Link block: #{content}"
|
|
194
|
+
InputSequencer.next_link_state(
|
|
195
|
+
block_name: content.fetch('block_name', nil),
|
|
196
|
+
document_filename: content.fetch('document_filename', nil),
|
|
197
|
+
prior_block_was_link: true
|
|
198
|
+
)
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
def load_document(_name)
|
|
202
|
+
# Stub: Load and return the content of the document
|
|
203
|
+
# In a real implementation, this would read the file and return its content
|
|
204
|
+
# "Block 1: Content of block 1\nBlock 2: Content of block 2\nLink: block_name 3, document_filename doc2"
|
|
205
|
+
$doc1.map { |key, value| "#{key}: #{value}" }.join("\n")
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
def parse_document(data)
|
|
209
|
+
load_document(data)
|
|
210
|
+
# Stub: Parse document content into blocks
|
|
211
|
+
# In a real implementation, this would split the document into named blocks
|
|
212
|
+
@blocks = $doc1
|
|
213
|
+
end
|
|
214
|
+
end
|
|
215
|
+
# MDE.singleton_class.prepend(ImwUx)
|
|
216
|
+
# MDE.prepend(ImwUx)
|
|
217
|
+
|
|
218
|
+
def main
|
|
219
|
+
if ARGV.empty?
|
|
220
|
+
puts "Usage: #{__FILE__} document_filename [block_name...]"
|
|
221
|
+
exit(1)
|
|
222
|
+
end
|
|
223
|
+
document_filename = ARGV.shift
|
|
224
|
+
initial_blocks = ARGV
|
|
225
|
+
mde = MDE.new(document_filename, initial_blocks)
|
|
226
|
+
mde.do_run
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
main
|
data/lib/link_history.rb
CHANGED
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
# encoding=utf-8
|
|
5
5
|
module MarkdownExec
|
|
6
6
|
class LinkState
|
|
7
|
-
attr_accessor :block_name, :document_filename,
|
|
8
|
-
:inherited_block_names, :inherited_dependencies, :inherited_lines
|
|
7
|
+
attr_accessor :block_name, :display_menu, :document_filename,
|
|
8
|
+
:inherited_block_names, :inherited_dependencies, :inherited_lines,
|
|
9
|
+
:prior_block_was_link
|
|
9
10
|
|
|
10
11
|
# Initialize the LinkState with keyword arguments for each attribute.
|
|
11
12
|
# @param block_name [String, nil] the name of the block.
|
|
@@ -13,13 +14,16 @@ module MarkdownExec
|
|
|
13
14
|
# @param inherited_block_names [Array<String>, nil] the names of the inherited blocks.
|
|
14
15
|
# @param inherited_dependencies [?, nil] the dependecy hierarcy.
|
|
15
16
|
# @param inherited_lines [Array<String>, nil] the inherited lines of code.
|
|
16
|
-
def initialize(block_name: nil, document_filename: nil,
|
|
17
|
-
inherited_block_names: [], inherited_dependencies: nil, inherited_lines: nil
|
|
17
|
+
def initialize(block_name: nil, display_menu: nil, document_filename: nil,
|
|
18
|
+
inherited_block_names: [], inherited_dependencies: nil, inherited_lines: nil,
|
|
19
|
+
prior_block_was_link: nil)
|
|
18
20
|
@block_name = block_name
|
|
21
|
+
@display_menu = display_menu
|
|
19
22
|
@document_filename = document_filename
|
|
20
23
|
@inherited_block_names = inherited_block_names
|
|
21
24
|
@inherited_dependencies = inherited_dependencies
|
|
22
25
|
@inherited_lines = inherited_lines
|
|
26
|
+
@prior_block_was_link = prior_block_was_link
|
|
23
27
|
end
|
|
24
28
|
|
|
25
29
|
# Creates an empty LinkState instance.
|
|
@@ -34,10 +38,12 @@ module MarkdownExec
|
|
|
34
38
|
def ==(other)
|
|
35
39
|
other.class == self.class &&
|
|
36
40
|
other.block_name == block_name &&
|
|
41
|
+
other.display_menu == display_menu &&
|
|
37
42
|
other.document_filename == document_filename &&
|
|
38
43
|
other.inherited_block_names == inherited_block_names &&
|
|
39
44
|
other.inherited_dependencies == inherited_dependencies &&
|
|
40
|
-
other.inherited_lines == inherited_lines
|
|
45
|
+
other.inherited_lines == inherited_lines &&
|
|
46
|
+
other.prior_block_was_link == prior_block_was_link
|
|
41
47
|
end
|
|
42
48
|
end
|
|
43
49
|
|
data/lib/markdown_exec.rb
CHANGED
|
@@ -10,6 +10,7 @@ require 'open3'
|
|
|
10
10
|
require 'optparse'
|
|
11
11
|
require 'shellwords'
|
|
12
12
|
require 'tmpdir'
|
|
13
|
+
# require 'tty-file'
|
|
13
14
|
require 'tty-prompt'
|
|
14
15
|
require 'yaml'
|
|
15
16
|
|
|
@@ -25,6 +26,7 @@ require_relative 'fcb'
|
|
|
25
26
|
require_relative 'filter'
|
|
26
27
|
require_relative 'fout'
|
|
27
28
|
require_relative 'hash_delegator'
|
|
29
|
+
require_relative 'input_sequencer'
|
|
28
30
|
require_relative 'markdown_exec/version'
|
|
29
31
|
require_relative 'mdoc'
|
|
30
32
|
require_relative 'option_value'
|
|
@@ -103,7 +105,6 @@ module MarkdownExec
|
|
|
103
105
|
|
|
104
106
|
##
|
|
105
107
|
#
|
|
106
|
-
# rubocop:disable Layout/LineLength
|
|
107
108
|
# :reek:DuplicateMethodCall { allow_calls: ['block', 'item', 'lm', 'opts', 'option', '@options', 'required_blocks'] }
|
|
108
109
|
# rubocop:enable Layout/LineLength
|
|
109
110
|
# :reek:MissingSafeMethod { exclude: [ read_configuration_file! ] }
|
|
@@ -293,15 +294,12 @@ module MarkdownExec
|
|
|
293
294
|
|
|
294
295
|
## position 1: block name (optional)
|
|
295
296
|
#
|
|
296
|
-
block_name =
|
|
297
|
-
@options[:block_name] = block_name if block_name.present?
|
|
297
|
+
@options[:block_name] = nil
|
|
298
298
|
@options[:input_cli_rest] = @rest
|
|
299
299
|
rescue FileMissingError
|
|
300
300
|
warn_format('finalize_cli_argument_processing',
|
|
301
301
|
"File missing -- #{$!}", { abort: true })
|
|
302
|
-
|
|
303
|
-
# @options[:filename] = ''
|
|
304
|
-
# exit 1
|
|
302
|
+
exit 1
|
|
305
303
|
rescue StandardError
|
|
306
304
|
error_handler('finalize_cli_argument_processing')
|
|
307
305
|
end
|
data/lib/mdoc.rb
CHANGED
|
@@ -70,10 +70,10 @@ module MarkdownExec
|
|
|
70
70
|
# @param name [String] The name of the code block to start the retrieval from.
|
|
71
71
|
# @return [Array<Hash>] An array of code blocks required by the specified code block.
|
|
72
72
|
#
|
|
73
|
-
def collect_block_dependencies(
|
|
74
|
-
name_block = get_block_by_anyname(
|
|
73
|
+
def collect_block_dependencies(anyname:)
|
|
74
|
+
name_block = get_block_by_anyname(anyname)
|
|
75
75
|
if name_block.nil? || name_block.keys.empty?
|
|
76
|
-
raise "Named code block `#{
|
|
76
|
+
raise "Named code block `#{anyname}` not found. (@#{__LINE__})"
|
|
77
77
|
end
|
|
78
78
|
|
|
79
79
|
nickname = name_block[:nickname] || name_block[:oname]
|
|
@@ -116,9 +116,9 @@ module MarkdownExec
|
|
|
116
116
|
# @param name [String] The name of the code block to start the collection from.
|
|
117
117
|
# @return [Array<String>] An array of strings containing the collected code blocks.
|
|
118
118
|
#
|
|
119
|
-
def collect_recursively_required_code(
|
|
119
|
+
def collect_recursively_required_code(anyname:, block_source:, label_body: true, label_format_above: nil,
|
|
120
120
|
label_format_below: nil)
|
|
121
|
-
block_search = collect_block_dependencies(
|
|
121
|
+
block_search = collect_block_dependencies(anyname: anyname)
|
|
122
122
|
if block_search[:blocks]
|
|
123
123
|
blocks = collect_wrapped_blocks(block_search[:blocks])
|
|
124
124
|
# &bc 'blocks.count:',blocks.count
|
|
@@ -453,12 +453,12 @@ if $PROGRAM_NAME == __FILE__
|
|
|
453
453
|
|
|
454
454
|
### broken test
|
|
455
455
|
def test_collect_block_dependencies
|
|
456
|
-
result = @doc.collect_block_dependencies('block3')[:blocks]
|
|
456
|
+
result = @doc.collect_block_dependencies(anyname: 'block3')[:blocks]
|
|
457
457
|
expected_result = [@table[0], @table[1], @table[2]]
|
|
458
458
|
assert_equal expected_result, result
|
|
459
459
|
|
|
460
460
|
assert_raises(RuntimeError) do
|
|
461
|
-
@doc.collect_block_dependencies('missing_block')
|
|
461
|
+
@doc.collect_block_dependencies(anyname: 'missing_block')
|
|
462
462
|
end
|
|
463
463
|
end
|
|
464
464
|
|
data/lib/menu.src.yml
CHANGED
|
@@ -121,6 +121,22 @@
|
|
|
121
121
|
:opt_name: dump_blocks_in_file
|
|
122
122
|
:procname: val_as_bool
|
|
123
123
|
|
|
124
|
+
- :arg_name: BOOL
|
|
125
|
+
:default: false
|
|
126
|
+
:description: Dump inherited block_names
|
|
127
|
+
:env_var: MDE_DUMP_INHERITED_BLOCK_NAMES
|
|
128
|
+
:long_name: dump-dump-inherited-block_names
|
|
129
|
+
:opt_name: dump_inherited_block_names
|
|
130
|
+
:procname: val_as_bool
|
|
131
|
+
|
|
132
|
+
- :arg_name: BOOL
|
|
133
|
+
:default: false
|
|
134
|
+
:description: Dump inherited dependencies
|
|
135
|
+
:env_var: MDE_DUMP_INHERITED_DEPENDENCIES
|
|
136
|
+
:long_name: dump-dump-inherited-dependencies
|
|
137
|
+
:opt_name: dump_inherited_dependencies
|
|
138
|
+
:procname: val_as_bool
|
|
139
|
+
|
|
124
140
|
- :arg_name: BOOL
|
|
125
141
|
:default: false
|
|
126
142
|
:description: Dump inherited lines
|
|
@@ -211,26 +227,12 @@
|
|
|
211
227
|
tell the first window
|
|
212
228
|
set bounds to {xoff, yoff, xoff + winWidth, yoff + winHeight}
|
|
213
229
|
tell the current session
|
|
214
|
-
write text "
|
|
215
|
-
write text "
|
|
216
|
-
write text "alias run_script=\"%{script_filespec}\""
|
|
217
|
-
write text "alias vim_script=\"vim \\\"%{script_filespec}\\\"\""
|
|
218
|
-
delay 1
|
|
219
|
-
|
|
220
|
-
write text "alias cat_output=\"cat -n \\\"%{output_filespec}\\\"\""
|
|
221
|
-
write text "alias grep_output=\"read -p Pattern: pattern && grep \\\"\\$pattern\\\" \\\"%{output_filespec}\\\"\""
|
|
222
|
-
write text "alias less_output=\"less \\\"%{output_filespec}\\\"\""
|
|
223
|
-
delay 1
|
|
224
|
-
|
|
225
|
-
write text "alias menu=\"select cmd in cat_script less_script run_script vim_script cat_output grep_output less_output exit; do eval \\\"\\$cmd\\\"; done\""
|
|
226
|
-
delay 1
|
|
227
|
-
|
|
230
|
+
write text "s=\"%{script_filespec}\""
|
|
231
|
+
write text "o=\"%{output_filespec}\""
|
|
228
232
|
write text "echo -ne \"\\033]; %{started_at} - %{document_filename} - %{block_name} \\007\""
|
|
229
233
|
write text "cd \"%{home}\""
|
|
230
|
-
write text "\"%{script_filename}\" | tee \"%{output_filespec}\""
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
write text "menu"
|
|
234
|
+
write text "# \"%{script_filename}\" | tee -a \"%{output_filespec}\""
|
|
235
|
+
write text "\"$s\" | tee -a \"$o\""
|
|
234
236
|
end tell
|
|
235
237
|
end tell
|
|
236
238
|
end tell'
|
|
@@ -606,9 +608,8 @@
|
|
|
606
608
|
:opt_name: menu_note_format
|
|
607
609
|
:procname: val_as_str
|
|
608
610
|
|
|
609
|
-
## all
|
|
610
|
-
|
|
611
|
-
- :default: "^(?<line>.*?) *$"
|
|
611
|
+
## all lines that do not start with "/ " are notes
|
|
612
|
+
- :default: "^(?<line>(?!/ ).*)?$"
|
|
612
613
|
:description: Pattern for notes in block selection menu
|
|
613
614
|
:env_var: MDE_MENU_NOTE_MATCH
|
|
614
615
|
:opt_name: menu_note_match
|
|
@@ -727,21 +728,25 @@
|
|
|
727
728
|
:env_var: MDE_OUTPUT_ASSIGNMENT_BEGIN
|
|
728
729
|
:opt_name: output_assignment_begin
|
|
729
730
|
:procname: val_as_str
|
|
731
|
+
|
|
730
732
|
- :default:
|
|
731
733
|
:description: Expression to match to stop collecting lines
|
|
732
734
|
:env_var: MDE_OUTPUT_ASSIGNMENT_END
|
|
733
|
-
:opt_name:
|
|
735
|
+
:opt_name: output_assignment_end
|
|
734
736
|
:procname: val_as_str
|
|
735
|
-
|
|
737
|
+
|
|
738
|
+
- :default: "%{line}"
|
|
736
739
|
:description: Format for assignments from output
|
|
737
740
|
:env_var: MDE_OUTPUT_ASSIGNMENT_FORMAT
|
|
738
741
|
:opt_name: output_assignment_format
|
|
739
742
|
:procname: val_as_str
|
|
740
|
-
|
|
743
|
+
|
|
744
|
+
- :default: "^ *(?<line>\\w+=.*?) *$"
|
|
741
745
|
:description: Pattern for assignments from output
|
|
742
746
|
:env_var: MDE_OUTPUT_ASSIGNMENT_MATCH
|
|
743
747
|
:opt_name: output_assignment_match
|
|
744
748
|
:procname: val_as_str
|
|
749
|
+
|
|
745
750
|
- :arg_name: BOOL
|
|
746
751
|
:default: false
|
|
747
752
|
:description: Display summary for execution
|
|
@@ -836,12 +841,24 @@
|
|
|
836
841
|
:opt_name: prompt_debounce
|
|
837
842
|
:procname: val_as_str
|
|
838
843
|
|
|
844
|
+
- :default: 'Name? '
|
|
845
|
+
:description: Prompt to enter a filespec
|
|
846
|
+
:env_var: MDE_PROMPT_ENTER_FILESPEC
|
|
847
|
+
:opt_name: prompt_enter_filespec
|
|
848
|
+
:procname: val_as_str
|
|
849
|
+
|
|
839
850
|
- :default: Exit
|
|
840
851
|
:description: Prompt to exit app
|
|
841
852
|
:env_var: MDE_PROMPT_EXIT
|
|
842
853
|
:opt_name: prompt_exit
|
|
843
854
|
:procname: val_as_str
|
|
844
855
|
|
|
856
|
+
- :default: Other
|
|
857
|
+
:description: Prompt for a custom file name
|
|
858
|
+
:env_var: MDE_PROMPT_FILESPEC_OTHER
|
|
859
|
+
:opt_name: prompt_filespec_other
|
|
860
|
+
:procname: val_as_str
|
|
861
|
+
|
|
845
862
|
- :default: 'No'
|
|
846
863
|
:description: Prompt for no
|
|
847
864
|
:env_var: MDE_PROMPT_NO
|
|
@@ -866,6 +883,12 @@
|
|
|
866
883
|
:opt_name: prompt_select_block
|
|
867
884
|
:procname: val_as_str
|
|
868
885
|
|
|
886
|
+
- :default: "\nChoose a file:"
|
|
887
|
+
:description: Prompt to select a file with inherited lines
|
|
888
|
+
:env_var: MDE_PROMPT_SELECT_CODE_FILE
|
|
889
|
+
:opt_name: prompt_select_code_file
|
|
890
|
+
:procname: val_as_str
|
|
891
|
+
|
|
869
892
|
- :default: "\nChoose a file:"
|
|
870
893
|
:description: Prompt to select a markdown document
|
|
871
894
|
:env_var: MDE_PROMPT_SELECT_MD
|
|
@@ -878,6 +901,12 @@
|
|
|
878
901
|
:opt_name: prompt_select_output
|
|
879
902
|
:procname: val_as_str
|
|
880
903
|
|
|
904
|
+
- :default: 'Expr: %{expr}'
|
|
905
|
+
:description: prompt_show_expr_format
|
|
906
|
+
:env_var: MDE_PROMPT_SHOW_EXPR_FORMAT
|
|
907
|
+
:opt_name: prompt_show_expr_format
|
|
908
|
+
:procname: val_as_str
|
|
909
|
+
|
|
881
910
|
- :default: Uninterrupted
|
|
882
911
|
:description: Uninterrupted execution
|
|
883
912
|
:env_var: MDE_PROMPT_UNINTERRUPTED
|
|
@@ -1062,12 +1091,18 @@
|
|
|
1062
1091
|
:opt_name: shell_code_label_format_above
|
|
1063
1092
|
:procname: val_as_str
|
|
1064
1093
|
|
|
1065
|
-
- :default: "# -v- +%{block_name} -o- %{document_filename} -v-"
|
|
1094
|
+
- :default: "# -v- +%{block_name} -o- %{document_filename} -o- %{time_now_date} -v-"
|
|
1066
1095
|
:description: shell_code_label_format_below
|
|
1067
1096
|
:env_var: MDE_SHELL_CODE_LABEL_FORMAT_BELOW
|
|
1068
1097
|
:opt_name: shell_code_label_format_below
|
|
1069
1098
|
:procname: val_as_str
|
|
1070
1099
|
|
|
1100
|
+
- :default: "%FT%TZ"
|
|
1101
|
+
:description: Format for time in code lael
|
|
1102
|
+
:env_var: MDE_SHELL_CODE_LABEL_TIME_FORMAT
|
|
1103
|
+
:opt_name: shell_code_label_time_format
|
|
1104
|
+
:procname: val_as_str
|
|
1105
|
+
|
|
1071
1106
|
- :description: List tab completions
|
|
1072
1107
|
:long_name: tab-completions
|
|
1073
1108
|
:opt_name: tab_completions
|
data/lib/menu.yml
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# MDE - Markdown Executor (
|
|
1
|
+
# MDE - Markdown Executor (2.0.0)
|
|
2
2
|
---
|
|
3
3
|
- :description: Show current configuration values
|
|
4
4
|
:procname: show_config
|
|
@@ -102,6 +102,20 @@
|
|
|
102
102
|
:long_name: dump-blocks-in-file
|
|
103
103
|
:opt_name: dump_blocks_in_file
|
|
104
104
|
:procname: val_as_bool
|
|
105
|
+
- :arg_name: BOOL
|
|
106
|
+
:default: false
|
|
107
|
+
:description: Dump inherited block_names
|
|
108
|
+
:env_var: MDE_DUMP_INHERITED_BLOCK_NAMES
|
|
109
|
+
:long_name: dump-dump-inherited-block_names
|
|
110
|
+
:opt_name: dump_inherited_block_names
|
|
111
|
+
:procname: val_as_bool
|
|
112
|
+
- :arg_name: BOOL
|
|
113
|
+
:default: false
|
|
114
|
+
:description: Dump inherited dependencies
|
|
115
|
+
:env_var: MDE_DUMP_INHERITED_DEPENDENCIES
|
|
116
|
+
:long_name: dump-dump-inherited-dependencies
|
|
117
|
+
:opt_name: dump_inherited_dependencies
|
|
118
|
+
:procname: val_as_bool
|
|
105
119
|
- :arg_name: BOOL
|
|
106
120
|
:default: false
|
|
107
121
|
:description: Dump inherited lines
|
|
@@ -173,21 +187,12 @@
|
|
|
173
187
|
yoff to xoff mod (screenHeight - winHeight)\n \n create window with
|
|
174
188
|
default profile\n tell the first window\n set bounds to {xoff,
|
|
175
189
|
yoff, xoff + winWidth, yoff + winHeight}\n tell the current session\n
|
|
176
|
-
\ write text \"
|
|
177
|
-
|
|
178
|
-
\ write text \"alias run_script=\\\"%{script_filespec}\\\"\"\n write
|
|
179
|
-
text \"alias vim_script=\\\"vim \\\\\\\"%{script_filespec}\\\\\\\"\\\"\"\n delay
|
|
180
|
-
1\n\n write text \"alias cat_output=\\\"cat -n \\\\\\\"%{output_filespec}\\\\\\\"\\\"\"\n
|
|
181
|
-
\ write text \"alias grep_output=\\\"read -p Pattern: pattern &&
|
|
182
|
-
grep \\\\\\\"\\\\$pattern\\\\\\\" \\\\\\\"%{output_filespec}\\\\\\\"\\\"\"\n write
|
|
183
|
-
text \"alias less_output=\\\"less \\\\\\\"%{output_filespec}\\\\\\\"\\\"\"\n delay
|
|
184
|
-
1\n\n write text \"alias menu=\\\"select cmd in cat_script less_script
|
|
185
|
-
run_script vim_script cat_output grep_output less_output exit; do eval \\\\\\\"\\\\$cmd\\\\\\\";
|
|
186
|
-
done\\\"\"\n delay 1\n\n write text \"echo -ne \\\"\\\\033];
|
|
190
|
+
\ write text \"s=\\\"%{script_filespec}\\\"\"\n write
|
|
191
|
+
text \"o=\\\"%{output_filespec}\\\"\"\n write text \"echo -ne \\\"\\\\033];
|
|
187
192
|
%{started_at} - %{document_filename} - %{block_name} \\\\007\\\"\"\n write
|
|
188
|
-
text \"cd \\\"%{home}\\\"\"\n write text \"\\\"%{script_filename}\\\"
|
|
189
|
-
| tee \\\"%{output_filespec}\\\"\"\n
|
|
190
|
-
|
|
193
|
+
text \"cd \\\"%{home}\\\"\"\n write text \"# \\\"%{script_filename}\\\"
|
|
194
|
+
| tee -a \\\"%{output_filespec}\\\"\"\n write text \"\\\"$s\\\"
|
|
195
|
+
| tee -a \\\"$o\\\"\"\n end tell\n end tell\n end tell'\n"
|
|
191
196
|
:description: execute_command_format
|
|
192
197
|
:env_var: MDE_EXECUTE_COMMAND_FORMAT
|
|
193
198
|
:opt_name: execute_command_format
|
|
@@ -500,7 +505,7 @@
|
|
|
500
505
|
:env_var: MDE_MENU_NOTE_FORMAT
|
|
501
506
|
:opt_name: menu_note_format
|
|
502
507
|
:procname: val_as_str
|
|
503
|
-
- :default: "^(?<line
|
|
508
|
+
- :default: "^(?<line>(?!/ ).*)?$"
|
|
504
509
|
:description: Pattern for notes in block selection menu
|
|
505
510
|
:env_var: MDE_MENU_NOTE_MATCH
|
|
506
511
|
:opt_name: menu_note_match
|
|
@@ -604,14 +609,14 @@
|
|
|
604
609
|
- :default:
|
|
605
610
|
:description: Expression to match to stop collecting lines
|
|
606
611
|
:env_var: MDE_OUTPUT_ASSIGNMENT_END
|
|
607
|
-
:opt_name:
|
|
612
|
+
:opt_name: output_assignment_end
|
|
608
613
|
:procname: val_as_str
|
|
609
|
-
- :default: "%{line}
|
|
614
|
+
- :default: "%{line}"
|
|
610
615
|
:description: Format for assignments from output
|
|
611
616
|
:env_var: MDE_OUTPUT_ASSIGNMENT_FORMAT
|
|
612
617
|
:opt_name: output_assignment_format
|
|
613
618
|
:procname: val_as_str
|
|
614
|
-
- :default: "^ *(
|
|
619
|
+
- :default: "^ *(?<line>\\w+=.*?) *$"
|
|
615
620
|
:description: Pattern for assignments from output
|
|
616
621
|
:env_var: MDE_OUTPUT_ASSIGNMENT_MATCH
|
|
617
622
|
:opt_name: output_assignment_match
|
|
@@ -702,11 +707,21 @@
|
|
|
702
707
|
:env_var: MDE_PROMPT_DEBOUNCE
|
|
703
708
|
:opt_name: prompt_debounce
|
|
704
709
|
:procname: val_as_str
|
|
710
|
+
- :default: 'Name? '
|
|
711
|
+
:description: Prompt to enter a filespec
|
|
712
|
+
:env_var: MDE_PROMPT_ENTER_FILESPEC
|
|
713
|
+
:opt_name: prompt_enter_filespec
|
|
714
|
+
:procname: val_as_str
|
|
705
715
|
- :default: Exit
|
|
706
716
|
:description: Prompt to exit app
|
|
707
717
|
:env_var: MDE_PROMPT_EXIT
|
|
708
718
|
:opt_name: prompt_exit
|
|
709
719
|
:procname: val_as_str
|
|
720
|
+
- :default: Other
|
|
721
|
+
:description: Prompt for a custom file name
|
|
722
|
+
:env_var: MDE_PROMPT_FILESPEC_OTHER
|
|
723
|
+
:opt_name: prompt_filespec_other
|
|
724
|
+
:procname: val_as_str
|
|
710
725
|
- :default: 'No'
|
|
711
726
|
:description: Prompt for no
|
|
712
727
|
:env_var: MDE_PROMPT_NO
|
|
@@ -731,6 +746,13 @@
|
|
|
731
746
|
:procname: val_as_str
|
|
732
747
|
- :default: |2-
|
|
733
748
|
|
|
749
|
+
Choose a file:
|
|
750
|
+
:description: Prompt to select a file with inherited lines
|
|
751
|
+
:env_var: MDE_PROMPT_SELECT_CODE_FILE
|
|
752
|
+
:opt_name: prompt_select_code_file
|
|
753
|
+
:procname: val_as_str
|
|
754
|
+
- :default: |2-
|
|
755
|
+
|
|
734
756
|
Choose a file:
|
|
735
757
|
:description: Prompt to select a markdown document
|
|
736
758
|
:env_var: MDE_PROMPT_SELECT_MD
|
|
@@ -743,6 +765,11 @@
|
|
|
743
765
|
:env_var: MDE_PROMPT_SELECT_OUTPUT
|
|
744
766
|
:opt_name: prompt_select_output
|
|
745
767
|
:procname: val_as_str
|
|
768
|
+
- :default: 'Expr: %{expr}'
|
|
769
|
+
:description: prompt_show_expr_format
|
|
770
|
+
:env_var: MDE_PROMPT_SHOW_EXPR_FORMAT
|
|
771
|
+
:opt_name: prompt_show_expr_format
|
|
772
|
+
:procname: val_as_str
|
|
746
773
|
- :default: Uninterrupted
|
|
747
774
|
:description: Uninterrupted execution
|
|
748
775
|
:env_var: MDE_PROMPT_UNINTERRUPTED
|
|
@@ -903,11 +930,17 @@
|
|
|
903
930
|
:env_var: MDE_SHELL_CODE_LABEL_FORMAT_ABOVE
|
|
904
931
|
:opt_name: shell_code_label_format_above
|
|
905
932
|
:procname: val_as_str
|
|
906
|
-
- :default: "# -v- +%{block_name} -o- %{document_filename} -
|
|
933
|
+
- :default: "# -v- +%{block_name} -o- %{document_filename} -o- %{time_now_date}
|
|
934
|
+
\ -v-"
|
|
907
935
|
:description: shell_code_label_format_below
|
|
908
936
|
:env_var: MDE_SHELL_CODE_LABEL_FORMAT_BELOW
|
|
909
937
|
:opt_name: shell_code_label_format_below
|
|
910
938
|
:procname: val_as_str
|
|
939
|
+
- :default: "%FT%TZ"
|
|
940
|
+
:description: Format for time in code lael
|
|
941
|
+
:env_var: MDE_SHELL_CODE_LABEL_TIME_FORMAT
|
|
942
|
+
:opt_name: shell_code_label_time_format
|
|
943
|
+
:procname: val_as_str
|
|
911
944
|
- :description: List tab completions
|
|
912
945
|
:long_name: tab-completions
|
|
913
946
|
:opt_name: tab_completions
|