cri 2.0.0 → 2.0.1
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.
- data/NEWS.md +9 -2
- data/lib/cri.rb +1 -1
- data/lib/cri/command.rb +4 -4
- data/test/test_command.rb +4 -4
- metadata +16 -3
data/NEWS.md
CHANGED
data/lib/cri.rb
CHANGED
data/lib/cri/command.rb
CHANGED
@@ -92,7 +92,7 @@ module Cri
|
|
92
92
|
dsl = Cri::CommandDSL.new
|
93
93
|
if string
|
94
94
|
dsl.instance_eval(string)
|
95
|
-
elsif block.arity
|
95
|
+
elsif [ -1, 0 ].include? block.arity
|
96
96
|
dsl.instance_eval(&block)
|
97
97
|
else
|
98
98
|
block.call(dsl)
|
@@ -133,7 +133,7 @@ module Cri
|
|
133
133
|
# @return [Cri::Command] The command itself
|
134
134
|
def modify(&block)
|
135
135
|
dsl = Cri::CommandDSL.new(self)
|
136
|
-
if block.arity
|
136
|
+
if [ -1, 0 ].include? block.arity
|
137
137
|
dsl.instance_eval(&block)
|
138
138
|
else
|
139
139
|
block.call(dsl)
|
@@ -170,7 +170,7 @@ module Cri
|
|
170
170
|
# Execute DSL
|
171
171
|
dsl = Cri::CommandDSL.new
|
172
172
|
dsl.name name unless name.nil?
|
173
|
-
if block.arity
|
173
|
+
if [ -1, 0 ].include? block.arity
|
174
174
|
dsl.instance_eval(&block)
|
175
175
|
else
|
176
176
|
block.call(dsl)
|
@@ -218,7 +218,7 @@ module Cri
|
|
218
218
|
exit 1
|
219
219
|
elsif commands.size > 1
|
220
220
|
$stderr.puts "#{self.name}: '#{name}' is ambiguous:"
|
221
|
-
$stderr.puts " #{commands.map { |c| c.name }.join(' ') }"
|
221
|
+
$stderr.puts " #{commands.map { |c| c.name }.sort.join(' ') }"
|
222
222
|
exit 1
|
223
223
|
else
|
224
224
|
commands[0]
|
data/test/test_command.rb
CHANGED
@@ -24,7 +24,7 @@ class Cri::CommandTestCase < Cri::TestCase
|
|
24
24
|
|
25
25
|
opts_strings = []
|
26
26
|
opts.each_pair { |k,v| opts_strings << "#{k}=#{v}" }
|
27
|
-
$stdout.puts opts_strings.join(',')
|
27
|
+
$stdout.puts opts_strings.sort.join(',')
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
@@ -115,7 +115,7 @@ class Cri::CommandTestCase < Cri::TestCase
|
|
115
115
|
simple_cmd.run(%w(-c -b x))
|
116
116
|
end
|
117
117
|
|
118
|
-
assert_equal [ 'Awesome moo!', '', 'ccc=true
|
118
|
+
assert_equal [ 'Awesome moo!', '', 'bbb=x,ccc=true' ], lines(out)
|
119
119
|
assert_equal [], lines(err)
|
120
120
|
end
|
121
121
|
|
@@ -189,7 +189,7 @@ class Cri::CommandTestCase < Cri::TestCase
|
|
189
189
|
end
|
190
190
|
|
191
191
|
assert_equal [ ], lines(out)
|
192
|
-
assert_equal [ "super: 's' is ambiguous:", " sub
|
192
|
+
assert_equal [ "super: 's' is ambiguous:", " sink sub" ], lines(err)
|
193
193
|
end
|
194
194
|
|
195
195
|
def test_invoke_nested_with_alias
|
@@ -211,7 +211,7 @@ class Cri::CommandTestCase < Cri::TestCase
|
|
211
211
|
end
|
212
212
|
|
213
213
|
def test_help_nested
|
214
|
-
help = nested_cmd.subcommands.
|
214
|
+
help = nested_cmd.subcommands.find { |cmd| cmd.name == 'sub' }.help
|
215
215
|
|
216
216
|
assert_match /^usage: super sub \[options\]/, help
|
217
217
|
end
|
metadata
CHANGED
@@ -1,8 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cri
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 13
|
4
5
|
prerelease:
|
5
|
-
|
6
|
+
segments:
|
7
|
+
- 2
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 2.0.1
|
6
11
|
platform: ruby
|
7
12
|
authors:
|
8
13
|
- Denis Defreyne
|
@@ -10,7 +15,8 @@ autorequire:
|
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
17
|
|
13
|
-
date: 2011-07-
|
18
|
+
date: 2011-07-04 00:00:00 +02:00
|
19
|
+
default_executable:
|
14
20
|
dependencies: []
|
15
21
|
|
16
22
|
description: Cri allows building easy-to-use commandline interfaces with support for subcommands.
|
@@ -47,6 +53,7 @@ files:
|
|
47
53
|
- test/test_option_parser.rb
|
48
54
|
- cri.gemspec
|
49
55
|
- .gemtest
|
56
|
+
has_rdoc: true
|
50
57
|
homepage: http://stoneship.org/software/cri/
|
51
58
|
licenses: []
|
52
59
|
|
@@ -61,17 +68,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
61
68
|
requirements:
|
62
69
|
- - ">="
|
63
70
|
- !ruby/object:Gem::Version
|
71
|
+
hash: 3
|
72
|
+
segments:
|
73
|
+
- 0
|
64
74
|
version: "0"
|
65
75
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
76
|
none: false
|
67
77
|
requirements:
|
68
78
|
- - ">="
|
69
79
|
- !ruby/object:Gem::Version
|
80
|
+
hash: 3
|
81
|
+
segments:
|
82
|
+
- 0
|
70
83
|
version: "0"
|
71
84
|
requirements: []
|
72
85
|
|
73
86
|
rubyforge_project:
|
74
|
-
rubygems_version: 1.
|
87
|
+
rubygems_version: 1.6.2
|
75
88
|
signing_key:
|
76
89
|
specification_version: 3
|
77
90
|
summary: a library for building easy-to-use commandline tools
|