menu_commander 0.1.0 → 0.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: 4cf72e4a3375daaa4a0693a693d24cd8bdd2b16ddaff9d5696c8b84cba683ca7
4
- data.tar.gz: 1238ecd337b8c51511b008ceda05160867b57dc9a64adcdaef57eb84c937d69c
3
+ metadata.gz: a4d53a183eadc9c1b1b4ae6c2a3945f5fab3c4cbf4c22d68242c6d8fc0a91ee8
4
+ data.tar.gz: 0d87631121b847fc344d5907846dd9d110477d4c0274fad5b6e52f6218e81a90
5
5
  SHA512:
6
- metadata.gz: 46e4e917ce083cde286e75e1673bfb412ca315716d924a0401787bfa04c1cc0de729ddbdebd6a5d8468ce5573848d61ef0e127029fb91891d3d84b079ac91795
7
- data.tar.gz: 58c9e748ea7e34baa187bb26213fa169f8adba2c022fa1c88ffd102c0e89135c7b4d278173cef28b5a2eb6ebc08e2561ff4df4b46cc3db7ce6272413e85dc5ef
6
+ metadata.gz: 419ac4ba40c923d195f393ef92e9ef246e0f40b25172b50b1197ad871cf7ed7ce170a6ee8234375e46b6ed1ade9c5a02c8d733119785566645ae1181d50e0769
7
+ data.tar.gz: 1b0db35c1a6700ec31b7505a9c89be3972e3f30f3344c7a711a98de7c4fc0b2099bea1055fd08e4c3bb7d3af87d15b3b1b4fd7919449b3ad5dc571b1fa757f61
data/README.md CHANGED
@@ -145,6 +145,27 @@ menu:
145
145
  branch: git branch
146
146
  ```
147
147
 
148
+ ### Multi-line commands
149
+
150
+ Providing an array to a menu, will join the array with '&&' to a single
151
+ command. Alternatively, you can use a simple YAML multi-line string.
152
+
153
+
154
+ ```yaml
155
+ # examples/multiline.yml
156
+ menu:
157
+ deploy:
158
+ - run tests
159
+ - git commit -am "automatic commit"
160
+ - git push
161
+
162
+ alternative: >
163
+ run tests &&
164
+ git commit -am "automatic commit" &&
165
+ git push
166
+ ```
167
+
168
+
148
169
  Menu File Location
149
170
  --------------------------------------------------
150
171
 
data/bin/menu CHANGED
@@ -12,6 +12,10 @@ rescue MenuCommander::Interrupt => e
12
12
  say! "\n#{e.message}"
13
13
  exit 0
14
14
 
15
+ rescue MenuCommander::Exit => e
16
+ say "#{e.message}" if e.message
17
+ exit 0
18
+
15
19
  rescue MenuCommander::MenuNotFound => e
16
20
  say! "#{e.message}"
17
21
  if e.paths and e.config
@@ -3,9 +3,7 @@ require 'mister_bin'
3
3
  module MenuCommander
4
4
  class CLI
5
5
  def self.router
6
- router = MisterBin::Runner.new version: VERSION,
7
- header: "CLI Menu Generator"
8
-
6
+ router = MisterBin::Runner.new
9
7
  router.route_all to: Command
10
8
  router
11
9
  end
@@ -5,13 +5,15 @@ module MenuCommander
5
5
  class Command < MisterBin::Command
6
6
  include Colsole
7
7
 
8
- help "Execute the menu"
8
+ help "Menu Commander"
9
9
  usage "menu [CONFIG --dry]"
10
- usage "menu (-h|--help)"
11
- option "-d --dry", "Dry run. Do not execute the command at the end, just show it."
10
+ usage "menu (-h|--help|--version)"
11
+ option "-d --dry", "Dry run - do not execute the command at the end, just show it"
12
+ option "--version", "Show version number"
12
13
  param "CONFIG", "The name of the menu config file without the .yml extension [default: menu]"
13
14
 
14
15
  def run
16
+ raise Exit, VERSION if args['--version']
15
17
  raise MenuNotFound.new(paths: menu_paths, config: config) unless menu_file
16
18
 
17
19
  if args['--dry']
@@ -1,6 +1,7 @@
1
1
  module MenuCommander
2
2
  class Error < StandardError; end
3
3
  class Interrupt < Interrupt; end
4
+ class Exit < SystemExit; end
4
5
 
5
6
  class MenuNotFound < Error
6
7
  # :nocov: - covered by external process
@@ -13,6 +13,8 @@ module MenuCommander
13
13
  def call(menu = nil)
14
14
  menu ||= config['menu']
15
15
  response = select menu
16
+ response = response.join ' && ' if response.is_a? Array
17
+
16
18
  if response.is_a? String
17
19
  params = {}
18
20
  placeholders(response).each do |key|
@@ -22,6 +24,7 @@ module MenuCommander
22
24
  response % params
23
25
  else
24
26
  call response
27
+
25
28
  end
26
29
  end
27
30
 
@@ -61,9 +64,7 @@ module MenuCommander
61
64
 
62
65
  def select(options, title = nil)
63
66
  title = title ? "> #{title}:" : ">"
64
- menu_config = { marker: '>', per_page: 10 }
65
- menu_config['filter'] = true if options.size > 10
66
- prompt.select title, options, menu_config
67
+ prompt.select title, options, symbols: { marker: '>' }, per_page: 10, filter: true
67
68
 
68
69
  rescue TTY::Reader::InputInterrupt
69
70
  # :nocov:
@@ -1,3 +1,3 @@
1
1
  module MenuCommander
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
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.0
4
+ version: 0.1.1
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-04-13 00:00:00.000000000 Z
11
+ date: 2019-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mister_bin
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0.18'
47
+ version: '0.19'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0.18'
54
+ version: '0.19'
55
55
  description: Easily create menus for any command line tool using simple YAML configuration
56
56
  email: db@dannyben.com
57
57
  executables: