markdown_exec 1.1.0 → 1.1.1

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: d34e8e9ff237ed338e50c0a03dfbb8c4bbd10e49f1f6ee54f54607ce19b96632
4
- data.tar.gz: 54f0ce617360be38233ed974f2cb8d5656e1b9f7671ed9f2ac819c2d66843eb1
3
+ metadata.gz: 0f8bb9f8a7a903a6b221ed8d04a5acb445e294be4c134202b9a71ba9e9f7c7ac
4
+ data.tar.gz: d26a89ae33f1aeaac70b40f3e31b3090fb50c6eb48874eeba435ce89825123fc
5
5
  SHA512:
6
- metadata.gz: e14f9203dd2c07b0b0fef5a71ebec355d1e1988c798bc0f5811bf6b97a0f8cd52066ff4dee2372c522248a920add287e3ac8567b3a68d7b885a3ec42266faa30
7
- data.tar.gz: b843ddd2e4b7b1b8eda9b4eb19823a32f758a422e27f84a779372e22321f4b16ce3307f51abb45e7bdbf92d14311ceedd110a1999203ffcf03ccb0ffa8f93b7e
6
+ metadata.gz: f177057c231ef950012abc922b6c3d9611e0b423df57cee07e6ac0e68864c18ce9b6a7cf640e165dbd8409d6ecefb199a3bb31643a7c5e31d5c241f17682545e
7
+ data.tar.gz: 9fb1a5d4274d2443e1ed9680978cfb12c76b46416a3ba76483addd19b61238446dce86793a039cfede131bdd11a4436ae693640ad279add82e24415a544b7b53
data/CHANGELOG.md CHANGED
@@ -34,9 +34,20 @@
34
34
 
35
35
  - [ ] re-exec last script v re-run named block in last script
36
36
  - [ ] repeat to reload last doc and block
37
- - [ ] option to output mixed stdin, stdout, stderr; labels: prefix and blocks
37
+ - [ ] option to log blended, timeline; stdin, stdout, stderr; labels: prefix and blocks
38
+ - [ ] ren logged_stdout_filename_prefix to saved_stdout_filename_prefix
38
39
 
39
- ## [1.0.1] - 2022-05-21
40
+ ## [1.1.1] - 2022-05-25
41
+
42
+ ### Added
43
+
44
+ - Post-install instructions to add tab completions permanently to the shell.
45
+
46
+ ### Changed
47
+
48
+ - Improve handling of threads ending while executing scripts.
49
+
50
+ ## [1.1.0] - 2022-05-21
40
51
 
41
52
  ### Added
42
53
 
@@ -53,14 +64,13 @@
53
64
  ### Changed
54
65
 
55
66
  - Exit option is at top of each menu.
56
- - Single-stage tab completion, defaut
67
+ - Single-stage tab completion, default
57
68
  - Presents matching options when current word starts with `-`
58
69
  - Presents directories and files otherwise.
59
70
  - Two-stage tab completion for option arguments.
60
71
  - When prior word is an option and current word is empty
61
72
  - Presents option type on first tab, eg `.BOOL.` for a boolean option.
62
73
  - Presents option default value on second tab, eg `0` for false.
63
- - Use 'bash' shell instead of default
64
74
  - Write STDOUT, STDERR, STDIN in sections to saved output file.
65
75
 
66
76
  ## [1.0.0] - 2022-04-26
data/Gemfile CHANGED
@@ -6,6 +6,7 @@ gemspec
6
6
  gem 'clipboard'
7
7
  gem 'erb'
8
8
  gem 'minitest', '~> 5.0'
9
+ gem 'mrdialog', '~> 1.0.3'
9
10
  gem 'rake', '~> 13.0'
10
11
  gem 'rubocop', '~> 1.21'
11
12
  gem 'rubocop-minitest', require: false
data/Gemfile.lock CHANGED
@@ -1,8 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- markdown_exec (1.1.0)
4
+ markdown_exec (1.1.1)
5
5
  clipboard (~> 1.3.6)
6
+ mrdialog (~> 1.0.3)
6
7
  open3 (~> 0.1.1)
7
8
  optparse (~> 0.1.1)
8
9
  tty-prompt (~> 0.23.1)
@@ -17,6 +18,7 @@ GEM
17
18
  erb (2.2.3)
18
19
  cgi
19
20
  minitest (5.15.0)
21
+ mrdialog (1.0.3)
20
22
  open3 (0.1.1)
21
23
  optparse (0.1.1)
22
24
  parallel (1.21.0)
@@ -68,6 +70,7 @@ DEPENDENCIES
68
70
  erb
69
71
  markdown_exec!
70
72
  minitest (~> 5.0)
73
+ mrdialog (~> 1.0.3)
71
74
  rake (~> 13.0)
72
75
  rubocop (~> 1.21)
73
76
  rubocop-minitest
data/README.md CHANGED
@@ -156,15 +156,28 @@ Append a command to load the completion script to your shell configuration file.
156
156
  echo "source $(mde --pwd)/bin/tab_completion.sh" >> ~/.bash_profile
157
157
  ```
158
158
 
159
+ ### Behavior
160
+
161
+ Press tab for completions appropriate to the current input.
162
+ `mde <...> <prior word> <current word>`
163
+
164
+ Completions are calculated based on the current word and the prior word.
165
+ 1. If the current word starts with `-`, present matching options, eg `--version` for the current word `--v`.
166
+ 2. Else, if the current word is empty and the prior word is an option that takes an argument, present the type of the argument, eg `.BOOL.` for the option `--user-must-approve`.
167
+ 3. Else, if the current word is the type of argument, from the rule above, present the default value for the option. e.g. `1` for the type `.BOOL.` for the option `--user-must-approve`.
168
+ 4. Else, if the current word is non-empty, list matching files and folders.
169
+
159
170
  ### Example Completions
160
171
 
161
- Type tab at end of any of the following commands to see the options.
162
- - `mde `
163
- - `mde -`
164
- - `mde --`
165
- - `mde --o`
166
- - `mde --filename my.md -`
167
- - `mde --filename my.md --`
172
+ In the table below, tab is indicated by `!`
173
+ | Input | Completions |
174
+ | :---: | :---: |
175
+ | `mde !` | local files and folders |
176
+ | `mde -!` | all options |
177
+ | `mde --!` | all options |
178
+ | `mde --v!` | `mde --version` |
179
+ | `mde --user-must-approve !` | `mde --user-must-approve .BOOL.`|
180
+ | `mde --user-must-approve .BOOL.!` | `mde --user-must-approve 1` |
168
181
 
169
182
  ## Example Blocks
170
183
 
@@ -197,34 +210,3 @@ The gem is available as open source under the terms of the [MIT License](https:/
197
210
  # Code of Conduct
198
211
 
199
212
  Everyone interacting in the MarkdownExec project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/markdown_exec/blob/master/CODE_OF_CONDUCT.md).
200
-
201
- ###
202
- i made a tool to help me execute shell commands for ansible, aws, etc.
203
-
204
- normally the scripts have a base configuration followed by one or more blocks of commands that must be executed with the base configuration.
205
-
206
- by storing the shell scripts in a markdown file, there is room for both code and explanatory text. the tool provides the interface that names all the code blocks in the file and allows the the user to select and preview the code to execute.
207
-
208
- i use it regularly to manage deployment processes that require dozens of steps with ease and re-playablity.
209
-
210
- the gem is hosted at `https://github.com/fareedst/markdown_exec`.
211
-
212
- please install the Ruby gem with `gem install markdown_exec` and let me know how the installation goes for you. i would like to see if your current deployment scripts can fit into this model.
213
-
214
- ```bash :test1
215
- files="$(ls -A .)"
216
- PS3='?'
217
- select filename in ${files}; do echo "You selected ${filename}"; break; done
218
-
219
- echo "-1"
220
- echo $0
221
- echo 'AA'
222
- echo 'name? '
223
- read name
224
- echo 'type? '
225
- read type
226
- echo 'BB'
227
- echo "name: $name"
228
- echo "type: $type"
229
- echo 'CC'
230
- ```
@@ -13,7 +13,7 @@ __filedirs_all()
13
13
  }
14
14
 
15
15
  _mde_echo_version() {
16
- echo "1.1.0"
16
+ echo "1.1.1"
17
17
  }
18
18
 
19
19
  _mde() {
@@ -140,4 +140,4 @@ _mde() {
140
140
 
141
141
  complete -o filenames -o nospace -F _mde mde
142
142
  # _mde_echo_version
143
- # echo "Updated: 2022-05-21 16:42:10 UTC"
143
+ # echo "Updated: 2022-05-26 01:40:10 UTC"
@@ -5,5 +5,5 @@ module MarkdownExec
5
5
  APP_NAME = 'MDE'
6
6
  BIN_NAME = 'mde'
7
7
  GEM_NAME = 'markdown_exec'
8
- VERSION = '1.1.0'
8
+ VERSION = '1.1.1'
9
9
  end
data/lib/markdown_exec.rb CHANGED
@@ -5,6 +5,7 @@
5
5
 
6
6
  require 'English'
7
7
  require 'clipboard'
8
+ require 'mrdialog'
8
9
  require 'open3'
9
10
  require 'optparse'
10
11
  require 'tty-prompt'
@@ -179,6 +180,8 @@ module MarkdownExec
179
180
  print line if opts[:output_stdout]
180
181
  yield nil, line, nil, exec_thr if block_given?
181
182
  end
183
+ rescue IOError => e
184
+ # thread killed, do nothing
182
185
  end
183
186
 
184
187
  t2 = Thread.new do
@@ -187,6 +190,8 @@ module MarkdownExec
187
190
  print line if opts[:output_stdout]
188
191
  yield nil, nil, line, exec_thr if block_given?
189
192
  end
193
+ rescue IOError => e
194
+ # thread killed, do nothing
190
195
  end
191
196
 
192
197
  in_thr = Thread.new do
@@ -247,6 +252,118 @@ module MarkdownExec
247
252
  list_recent_output: -> { fout_list list_recent_output },
248
253
  list_recent_scripts: -> { fout_list list_recent_scripts },
249
254
  pwd: -> { fout File.expand_path('..', __dir__) },
255
+ pwd3: lambda {
256
+ text = 'A B C'
257
+ items = []
258
+ Struct.new('BuildListData', :tag, :item, :status)
259
+ data = Struct::BuildListData.new
260
+
261
+ data.tag = '1'
262
+ data.item = 'Item number 1'
263
+ data.status = true
264
+ items.push(data.to_a)
265
+
266
+ data = Struct::BuildListData.new
267
+ data.tag = '2'
268
+ data.item = 'Item number 2'
269
+ data.status = false
270
+ items.push(data.to_a)
271
+
272
+ data = Struct::BuildListData.new
273
+ data.tag = '3'
274
+ data.item = 'Item number 3'
275
+ data.status = false
276
+ items.push(data.to_a)
277
+
278
+ data = Struct::BuildListData.new
279
+ data.tag = '4'
280
+ data.item = 'Item number 4'
281
+ data.status = true
282
+ items.push(data.to_a)
283
+
284
+ data = Struct::BuildListData.new
285
+ data.tag = '5'
286
+ data.item = 'Item number 5'
287
+ data.status = false
288
+ items.push(data.to_a)
289
+
290
+ data = Struct::BuildListData.new
291
+ data.tag = '6'
292
+ data.item = 'Item number 6'
293
+ data.status = true
294
+ items.push(data.to_a)
295
+
296
+ dialog = MRDialog.new
297
+ dialog.clear = true
298
+ dialog.shadow = false
299
+ dialog.title = 'BUILDLIST'
300
+ # dialog.logger = Logger.new(ENV["HOME"] + "/dialog_" + ME + ".log")
301
+
302
+ height = 0
303
+ width = 0
304
+ listheight = 0
305
+
306
+ selected_items = dialog.buildlist(text, items, height, width, listheight)
307
+ exit_code = dialog.exit_code
308
+ puts "Exit code: #{exit_code}"
309
+ puts 'Selecetd tags:'
310
+ selected_items.each do |item|
311
+ puts " '#{item}'"
312
+ end
313
+ },
314
+ pwd1: lambda {
315
+ dialog = MRDialog.new
316
+ dialog.clear = true
317
+ dialog.title = 'YES/NO BOX'
318
+ puts "yesno: #{dialog.yesno('ABC', 0, 0)}"
319
+ },
320
+ pwd2: lambda {
321
+ dialog = MRDialog.new
322
+ # dialog.logger = Logger.new(ENV["HOME"] + "/dialog_" + ME + ".log")
323
+ dialog.clear = true
324
+ dialog.title = 'MENU BOX'
325
+ text = 'textextst'
326
+ items = []
327
+ menu_data = Struct.new(:tag, :item)
328
+ data = menu_data.new
329
+ data.tag = 'Linux'
330
+ data.item = 'The Great Unix Clone for 386/486'
331
+ items.push(data.to_a)
332
+
333
+ data = menu_data.new
334
+ data.tag = 'NetBSD'
335
+ data.item = 'Another free Unix Clone for 386/486'
336
+ items.push(data.to_a)
337
+
338
+ data = menu_data.new
339
+ data.tag = 'OS/2'
340
+ data.item = 'IBM OS/2'
341
+ items.push(data.to_a)
342
+
343
+ data = menu_data.new
344
+ data.tag = 'WIN NT'
345
+ data.item = 'Microsoft Windows NT'
346
+ items.push(data.to_a)
347
+
348
+ data = menu_data.new
349
+ data.tag = 'PCDOS'
350
+ data.item = 'IBM PC DOS'
351
+ items.push(data.to_a)
352
+
353
+ data = menu_data.new
354
+ data.tag = 'MSDOS'
355
+ data.item = 'Microsoft DOS'
356
+ items.push(data.to_a)
357
+
358
+ height = 0
359
+ width = 0
360
+ menu_height = 4
361
+
362
+ selected_item = dialog.menu(text, items, height, width, menu_height)
363
+
364
+ puts "Selected item: #{selected_item}"
365
+ },
366
+ # pwd: -> { fout `dialog --yesno "ABC" 99 99` },
250
367
  run_last_script: -> { run_last_script },
251
368
  select_recent_output: -> { select_recent_output },
252
369
  select_recent_script: -> { select_recent_script },
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: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fareed Stevenson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-21 00:00:00.000000000 Z
11
+ date: 2022-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clipboard
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.3.6
27
+ - !ruby/object:Gem::Dependency
28
+ name: mrdialog
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 1.0.3
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 1.0.3
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: open3
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -120,7 +134,14 @@ metadata:
120
134
  homepage_uri: https://rubygems.org/gems/markdown_exec
121
135
  rubygems_mfa_required: 'true'
122
136
  source_code_uri: https://github.com/fareedst/markdown_exec
123
- post_install_message:
137
+ post_install_message: |2+
138
+
139
+ To install tab completion:
140
+ - Append a command to load the completion script to your shell configuration file.
141
+ - This gem must be installed and executable for the command to be composed correctly.
142
+
143
+ echo "source $(mde --pwd)/bin/tab_completion.sh" >> ~/.bash_profile
144
+
124
145
  rdoc_options: []
125
146
  require_paths:
126
147
  - lib
@@ -140,3 +161,4 @@ signing_key:
140
161
  specification_version: 4
141
162
  summary: Interactively select and execute fenced code blocks in markdown files.
142
163
  test_files: []
164
+ ...