consoler 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -3
- data/lib/consoler/application.rb +22 -1
- data/lib/consoler/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: 0010d4720e7d43dfb1f4d565b75907891be9d249722835f31ef7db564c952b86
|
4
|
+
data.tar.gz: 5f5ea095545606670b4d20b33c3210fa892e91427a4f7cdf273e15fe941cf4e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e7135eb513b261165986c85f724960991429fae68aa8a86b357209e804a6293189094dc987b91c64f03f1c29535865a81726147e9a4173d6f5ae9cbd87ef76a
|
7
|
+
data.tar.gz: 49647acd0e61309181a6f0f38098b21ccfaf155549a737ebc2335dacd28d087f5562ad79577d54f18921ff42b55a1edb10e41577d92508cab4b975a48cadc816
|
data/README.md
CHANGED
@@ -55,20 +55,20 @@ gem install consoler
|
|
55
55
|
or add to your `Gemfile` for applications
|
56
56
|
|
57
57
|
```ruby
|
58
|
-
gem 'consoler', '~> 1.
|
58
|
+
gem 'consoler', '~> 1.2.0'
|
59
59
|
```
|
60
60
|
|
61
61
|
or to your `.gemspec` file for gems
|
62
62
|
|
63
63
|
```ruby
|
64
64
|
Gem::Specification.new do |spec|
|
65
|
-
spec.add_dependency 'consoler', '~> 1.
|
65
|
+
spec.add_dependency 'consoler', '~> 1.2.0'
|
66
66
|
end
|
67
67
|
```
|
68
68
|
|
69
69
|
## Docs
|
70
70
|
|
71
|
-
Full API documentation can the found here: https://www.rubydoc.info/
|
71
|
+
Full API documentation can the found here: https://www.rubydoc.info/gems/consoler/1.2.0
|
72
72
|
|
73
73
|
### API
|
74
74
|
|
@@ -142,6 +142,12 @@ ruby app.rb build --env production dist
|
|
142
142
|
|
143
143
|
# deploy
|
144
144
|
ruby app.rb deploy --verbose
|
145
|
+
|
146
|
+
# or, you can use command shortcuts. this works by prefix matching and only if
|
147
|
+
# there is one match, exact matches always have priority
|
148
|
+
ruby app.rb b --env production dist
|
149
|
+
ruby app.rb d --verbose
|
150
|
+
|
145
151
|
```
|
146
152
|
|
147
153
|
#### Options definition
|
data/lib/consoler/application.rb
CHANGED
@@ -112,10 +112,31 @@ module Consoler
|
|
112
112
|
# @return [(mixed, Boolean)] Result of the command, and, did the args match a command at all
|
113
113
|
def _run(args)
|
114
114
|
arg = args.shift
|
115
|
+
|
116
|
+
return [nil, false] if arg.nil?
|
117
|
+
|
115
118
|
arguments = Consoler::Arguments.new args
|
119
|
+
exact_matches = []
|
120
|
+
partial_matches = []
|
116
121
|
|
117
122
|
@commands.each do |command|
|
118
123
|
if command.command == arg
|
124
|
+
exact_matches.push command
|
125
|
+
elsif command.command.start_with? arg
|
126
|
+
partial_matches.push command
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
# we only allow a single partial match to prevent ambiguity
|
131
|
+
partial_match = if partial_matches.size == 1
|
132
|
+
partial_matches[0]
|
133
|
+
end
|
134
|
+
|
135
|
+
unless exact_matches.empty? && partial_match.nil?
|
136
|
+
matches = exact_matches
|
137
|
+
matches.push partial_match unless partial_match.nil?
|
138
|
+
|
139
|
+
matches.each do |command|
|
119
140
|
# the matched command contains a subapp, run subapp with the same
|
120
141
|
# arguments (excluding the arg that matched this command)
|
121
142
|
if command.action.instance_of?(Consoler::Application)
|
@@ -202,7 +223,7 @@ module Consoler
|
|
202
223
|
normalized_name = _normalize name
|
203
224
|
|
204
225
|
if parameter_name == normalized_name
|
205
|
-
|
226
|
+
break value
|
206
227
|
end
|
207
228
|
end
|
208
229
|
end
|
data/lib/consoler/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: consoler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-03-
|
11
|
+
date: 2019-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|