climate 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/climate/parser.rb +5 -2
- data/lib/climate/version.rb +1 -1
- data/lib/climate.rb +4 -0
- metadata +4 -4
data/lib/climate/parser.rb
CHANGED
@@ -32,6 +32,7 @@ module Climate
|
|
32
32
|
|
33
33
|
def optional? ; spec.has_key?(:default) ; end
|
34
34
|
def required? ; ! optional? ; end
|
35
|
+
def multi? ; spec[:multi] ; end
|
35
36
|
|
36
37
|
def spec ; @specs ||= parser.specs[@name] ; end
|
37
38
|
|
@@ -44,7 +45,7 @@ module Climate
|
|
44
45
|
end
|
45
46
|
|
46
47
|
def short_usage
|
47
|
-
short && (type == :flag ? "-#{short}" : "-#{short}<#{
|
48
|
+
short && (type == :flag ? "-#{short}" : "-#{short} <#{name}>")
|
48
49
|
end
|
49
50
|
|
50
51
|
def usage(options={})
|
@@ -56,6 +57,8 @@ module Climate
|
|
56
57
|
|
57
58
|
if optional? && !options.fetch(:hide_optional, false)
|
58
59
|
"[#{help}]"
|
60
|
+
elsif multi? && !options.fetch(:hide_optional, false)
|
61
|
+
"[#{help}...]"
|
59
62
|
else
|
60
63
|
help
|
61
64
|
end
|
@@ -170,7 +173,7 @@ module Climate
|
|
170
173
|
elsif (m = /option (.+) must be specified/.match(e.message))
|
171
174
|
raise MissingArgumentError.new(m[1], command)
|
172
175
|
else
|
173
|
-
raise
|
176
|
+
raise CommandError.new(e.message, command)
|
174
177
|
end
|
175
178
|
end
|
176
179
|
|
data/lib/climate/version.rb
CHANGED
data/lib/climate.rb
CHANGED
@@ -22,6 +22,10 @@ module Climate
|
|
22
22
|
$stderr.puts("Missing argument: #{e.message}")
|
23
23
|
print_usage(e.command_class)
|
24
24
|
exit(1)
|
25
|
+
rescue CommandError => e
|
26
|
+
$stderr.puts(e.message)
|
27
|
+
print_usage(e.command_class)
|
28
|
+
exit(1)
|
25
29
|
rescue => e
|
26
30
|
$stderr.puts("Unexpected error: #{e.class.name} - #{e.message}")
|
27
31
|
$stderr.puts(e.backtrace)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: climate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 4
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.4.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Nick Griffiths
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-08-
|
18
|
+
date: 2012-08-29 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: trollop
|