menu_commander 0.1.2 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0a654387581a9294b1f966462348cfa72bdca3e3686f362927a5895c8e0e85ce
4
- data.tar.gz: de697ea0192672f4dc5e55e1d82083c369e4bebd6a610197f6501d197392c69f
3
+ metadata.gz: 7d7fe866ab431b21325f0e4f8adc8ff913bc76b3a50d0f8385fdf0dcf33dbf2c
4
+ data.tar.gz: c3bd55de579f4f8201680b1e7694f2156ba4ed60864c6532236019dc98ad4d56
5
5
  SHA512:
6
- metadata.gz: a66bedf0ce90c8d161b4d296c76fa91ac0a9bb614921381fcd3607f7fe568d29806a5ffe66b4cb2ca60e38e78b83bba7d00eaa0b9505c3d02c9f7e0974328acd
7
- data.tar.gz: 9bf17c66d38b66a11b2e01c758c9c8d21e134cb2d34bd5a7bc10eb8b4c70a665eb5eb374adc30587f1f2ff1217d38ff8ed956625ce22a12c12637484e80b2e71
6
+ metadata.gz: a537d45c0513518ffed2540f4e0cba02018265da124322fee96a31399858a45b3c58f3fa2e9459fcf472775173c128b76e4d5a5c6100c7223d376fde9da8781c
7
+ data.tar.gz: '0986d862f6660ae0858bf0d6fb67d04d99ee24e4eb86e0da41c334e96e36c05b640cef3bca84c60c2f2d45dc3faedde1615b2479794ec6df9cea44bbdc7e80a8'
@@ -1,25 +1,32 @@
1
1
  require 'mister_bin'
2
- require 'colsole'
3
2
 
4
3
  module MenuCommander
5
4
  class Command < MisterBin::Command
6
- include Colsole
7
-
8
5
  help "Menu Commander"
9
- usage "menu [CONFIG --dry]"
6
+
7
+ usage "menu [CONFIG --dry --loop]"
10
8
  usage "menu (-h|--help|--version)"
9
+
11
10
  option "-d --dry", "Dry run - do not execute the command at the end, just show it"
11
+ option "-l --loop", "Reopen the menu after executing the selected command"
12
12
  option "--version", "Show version number"
13
+
13
14
  param "CONFIG", "The name of the menu config file without the .yml extension [default: menu]"
14
15
 
16
+ example "menu --dry"
17
+ example "menu production --loop"
18
+ example "menu -ld"
19
+
20
+ attr_reader :last_command
21
+
15
22
  def run
16
23
  raise Exit, VERSION if args['--version']
17
24
  raise MenuNotFound.new(paths: menu_paths, config: config) unless menu_file
18
25
 
19
- if args['--dry']
20
- say "$ !txtpur!#{command}"
26
+ if args['--loop']
27
+ run_looped_menu
21
28
  else
22
- exec command
29
+ run_menu
23
30
  end
24
31
  end
25
32
 
@@ -27,11 +34,26 @@ module MenuCommander
27
34
  @menu ||= Menu.new menu_file
28
35
  end
29
36
 
30
- def command
31
- @command ||= menu.call
37
+ private
38
+
39
+ def run_looped_menu
40
+ loop do
41
+ run_menu
42
+ say ""
43
+ break if ENV['MENU_COMMANDER_ENV'] == 'test'
44
+ end
32
45
  end
33
46
 
34
- private
47
+ def run_menu
48
+ command = menu.call
49
+ @last_command = command
50
+
51
+ if args['--dry']
52
+ say "$ !txtpur!#{command}".strip
53
+ else
54
+ system command
55
+ end
56
+ end
35
57
 
36
58
  def menu_file
37
59
  @menu_file ||= menu_file!
@@ -1,3 +1,3 @@
1
1
  module MenuCommander
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
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.1.2
4
+ version: 0.1.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-16 00:00:00.000000000 Z
11
+ date: 2019-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mister_bin