menu_commander 0.2.2 → 0.2.3
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/README.md +7 -3
- data/bin/menu +4 -2
- data/lib/menu_commander/command.rb +21 -5
- data/lib/menu_commander/menu_options.rb +2 -1
- data/lib/menu_commander/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23e8aac2db7da03b17fe9b14fb148c40465b30720e89a0b21260ac0a27089fdf
|
4
|
+
data.tar.gz: 548033b637bf604419d6c975b191082d636fe3541c3aaf6e0a11ab6e49342cf8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25b10ab2564ff96d6353ac1100cbedd223e444c83796fd1ed9991ba8dcf10aedd0a984f40e0326b4f94e1d4e9df2d0483145cd18d4f0de9098eba2881ddc324d
|
7
|
+
data.tar.gz: 9e995b8afa4b0b4aa610b90addd94639f453cf6880f940fa77f6147d9b5a0b44c924125cc4a81240731ef20f153354b24ec058014a7f21ce475e8ac55165e305
|
data/README.md
CHANGED
@@ -272,6 +272,7 @@ You can tweak several aspects of the menu by adding an `options` section
|
|
272
272
|
in your YAML file.
|
273
273
|
|
274
274
|
```yaml
|
275
|
+
# Optional menu configuration
|
275
276
|
options:
|
276
277
|
# Show header text
|
277
278
|
header: Hello
|
@@ -304,12 +305,15 @@ options:
|
|
304
305
|
# Show the command after execution
|
305
306
|
echo: true
|
306
307
|
|
307
|
-
# Marker to use when echoing the command
|
308
|
-
|
308
|
+
# Marker to use when echoing the command and it was successful
|
309
|
+
echo_marker_success: "==>"
|
310
|
+
|
311
|
+
# Marker to use when echoing the command and it failed
|
312
|
+
echo_marker_error: "ERROR ==>"
|
309
313
|
|
310
314
|
```
|
311
315
|
|
312
|
-
> See: [examples/
|
316
|
+
> See: [examples/options.yml](examples/options.yml)
|
313
317
|
|
314
318
|
|
315
319
|
|
data/bin/menu
CHANGED
@@ -8,8 +8,10 @@ router = MenuCommander::CLI.router
|
|
8
8
|
begin
|
9
9
|
exit router.run ARGV
|
10
10
|
|
11
|
-
rescue MenuCommander::Interrupt => e
|
12
|
-
|
11
|
+
rescue MenuCommander::Interrupt, Interrupt => e
|
12
|
+
message = e.message
|
13
|
+
message = 'Interrupted... Goodbye' if message.empty?
|
14
|
+
say! "\n#{message}"
|
13
15
|
exit 0
|
14
16
|
|
15
17
|
rescue MenuCommander::Exit => e
|
@@ -23,20 +23,23 @@ module MenuCommander
|
|
23
23
|
def run
|
24
24
|
verify_sanity
|
25
25
|
say "#{menu.options.header}\n" if menu.options.header
|
26
|
+
success = true
|
26
27
|
|
27
28
|
if args['--loop']
|
28
29
|
run_looped_menu
|
29
30
|
else
|
30
|
-
run_menu
|
31
|
+
success = run_menu
|
31
32
|
end
|
33
|
+
|
34
|
+
success ? 0 : 1
|
32
35
|
end
|
33
36
|
|
37
|
+
private
|
38
|
+
|
34
39
|
def menu
|
35
40
|
@menu ||= Menu.new menu_file
|
36
41
|
end
|
37
42
|
|
38
|
-
private
|
39
|
-
|
40
43
|
def verify_sanity
|
41
44
|
raise Exit, VERSION if args['--version']
|
42
45
|
raise MenuNotFound.new(paths: menu_paths, config: config) unless menu_file
|
@@ -59,9 +62,22 @@ module MenuCommander
|
|
59
62
|
say "$ !txtpur!#{command}".strip if args['--confirm'] or args['--dry']
|
60
63
|
|
61
64
|
execute = prompt.yes?("Execute?") if args['--confirm']
|
62
|
-
system
|
65
|
+
success = execute ? system(command) : false
|
66
|
+
|
67
|
+
echo_footer success, command if menu.options.echo
|
68
|
+
success
|
69
|
+
end
|
70
|
+
|
71
|
+
def echo_footer(success, command)
|
72
|
+
if success
|
73
|
+
marker = menu.options.echo_marker_success
|
74
|
+
color = :txtblu
|
75
|
+
else
|
76
|
+
marker = menu.options.echo_marker_error
|
77
|
+
color = :txtred
|
78
|
+
end
|
63
79
|
|
64
|
-
say "
|
80
|
+
say "!#{color}!#{marker} #{command}".strip
|
65
81
|
end
|
66
82
|
|
67
83
|
def menu_file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: menu_commander
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danny Ben Shitrit
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-10-
|
11
|
+
date: 2019-10-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mister_bin
|