cli 1.2.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +5 -7
- data/Gemfile.lock +29 -37
- data/README.md +43 -44
- data/Rakefile +1 -28
- data/cli.gemspec +14 -84
- data/examples/httpclient +6 -6
- data/examples/ls +4 -4
- data/examples/processor +5 -5
- data/examples/sinatra +9 -9
- data/lib/cli/dsl.rb +3 -3
- data/rdoc/CLI/Arguments.html +178 -0
- data/rdoc/CLI/DSL/Argument.html +200 -0
- data/rdoc/CLI/DSL/Arguments.html +172 -0
- data/rdoc/CLI/DSL/Base.html +154 -0
- data/rdoc/CLI/DSL/Cast.html +152 -0
- data/rdoc/CLI/DSL/Description.html +150 -0
- data/rdoc/CLI/DSL/Input.html +143 -0
- data/rdoc/CLI/DSL/MultiDefault.html +151 -0
- data/rdoc/CLI/DSL/Option.html +143 -0
- data/rdoc/CLI/DSL/Options.html +142 -0
- data/rdoc/CLI/DSL/Switch.html +267 -0
- data/rdoc/CLI/DSL/Value.html +238 -0
- data/rdoc/CLI/DSL.html +91 -0
- data/rdoc/CLI/Options.html +200 -0
- data/rdoc/CLI/ParserError/ArgumentNameSpecifiedTwice.html +138 -0
- data/rdoc/CLI/ParserError/LongNameSpecifiedTwiceError.html +138 -0
- data/rdoc/CLI/ParserError/MultipleArgumentsSpecifierError.html +138 -0
- data/rdoc/CLI/ParserError/NameArgumetNotSymbolError.html +138 -0
- data/rdoc/CLI/ParserError/OptionsArgumentNotHashError.html +138 -0
- data/rdoc/CLI/ParserError/ShortNameIsInvalidError.html +138 -0
- data/rdoc/CLI/ParserError/ShortNameNotSymbolError.html +138 -0
- data/rdoc/CLI/ParserError/ShortNameSpecifiedTwiceError.html +138 -0
- data/rdoc/CLI/ParserError.html +97 -0
- data/rdoc/CLI/ParsingError/CastError.html +138 -0
- data/rdoc/CLI/ParsingError/MandatoryArgumentNotSpecifiedError.html +138 -0
- data/rdoc/CLI/ParsingError/MandatoryOptionsNotSpecifiedError.html +138 -0
- data/rdoc/CLI/ParsingError/MissingOptionValueError.html +138 -0
- data/rdoc/CLI/ParsingError/UnknownSwitchError.html +138 -0
- data/rdoc/CLI/ParsingError/UsageError.html +97 -0
- data/rdoc/CLI/ParsingError.html +97 -0
- data/rdoc/CLI/Switches.html +306 -0
- data/rdoc/CLI/Values.html +202 -0
- data/rdoc/CLI.html +652 -0
- data/rdoc/README_md.html +553 -0
- data/rdoc/created.rid +7 -0
- data/rdoc/css/fonts.css +167 -0
- data/rdoc/css/rdoc.css +639 -0
- data/rdoc/fonts/Lato-Light.ttf +0 -0
- data/rdoc/fonts/Lato-LightItalic.ttf +0 -0
- data/rdoc/fonts/Lato-Regular.ttf +0 -0
- data/rdoc/fonts/Lato-RegularItalic.ttf +0 -0
- data/rdoc/fonts/SourceCodePro-Bold.ttf +0 -0
- data/rdoc/fonts/SourceCodePro-Regular.ttf +0 -0
- data/rdoc/images/add.png +0 -0
- data/rdoc/images/arrow_up.png +0 -0
- data/rdoc/images/brick.png +0 -0
- data/rdoc/images/brick_link.png +0 -0
- data/rdoc/images/bug.png +0 -0
- data/rdoc/images/bullet_black.png +0 -0
- data/rdoc/images/bullet_toggle_minus.png +0 -0
- data/rdoc/images/bullet_toggle_plus.png +0 -0
- data/rdoc/images/date.png +0 -0
- data/rdoc/images/delete.png +0 -0
- data/rdoc/images/find.png +0 -0
- data/rdoc/images/loadingAnimation.gif +0 -0
- data/rdoc/images/macFFBgHack.png +0 -0
- data/rdoc/images/package.png +0 -0
- data/rdoc/images/page_green.png +0 -0
- data/rdoc/images/page_white_text.png +0 -0
- data/rdoc/images/page_white_width.png +0 -0
- data/rdoc/images/plugin.png +0 -0
- data/rdoc/images/ruby.png +0 -0
- data/rdoc/images/tag_blue.png +0 -0
- data/rdoc/images/tag_green.png +0 -0
- data/rdoc/images/transparent.png +0 -0
- data/rdoc/images/wrench.png +0 -0
- data/rdoc/images/wrench_orange.png +0 -0
- data/rdoc/images/zoom.png +0 -0
- data/rdoc/index.html +120 -0
- data/rdoc/js/darkfish.js +84 -0
- data/rdoc/js/navigation.js +105 -0
- data/rdoc/js/navigation.js.gz +0 -0
- data/rdoc/js/search.js +110 -0
- data/rdoc/js/search_index.js +1 -0
- data/rdoc/js/search_index.js.gz +0 -0
- data/rdoc/js/searcher.js +229 -0
- data/rdoc/js/searcher.js.gz +0 -0
- data/rdoc/table_of_contents.html +533 -0
- data/spec/argument_spec.rb +122 -99
- data/spec/cli_spec.rb +27 -28
- data/spec/conflict_reporting_spec.rb +16 -17
- data/spec/option_spec.rb +79 -56
- data/spec/separator_spec.rb +19 -20
- data/spec/stdin_spec.rb +13 -14
- data/spec/switch_spec.rb +15 -16
- data/spec/usage_spec.rb +80 -81
- metadata +91 -104
- data/.document +0 -5
- data/.rspec +0 -1
- data/VERSION +0 -1
- data/features/cli.feature +0 -9
- data/features/step_definitions/cli_steps.rb +0 -0
- data/features/support/env.rb +0 -13
data/spec/option_spec.rb
CHANGED
@@ -6,32 +6,56 @@ describe CLI do
|
|
6
6
|
ps = CLI.new do
|
7
7
|
option :location
|
8
8
|
end.parse(['--location', 'singapore'])
|
9
|
-
|
10
|
-
|
9
|
+
expect(ps.location).to be_a String
|
10
|
+
expect(ps.location).to eq 'singapore'
|
11
11
|
end
|
12
12
|
|
13
13
|
it "should handle short option names" do
|
14
14
|
ps = CLI.new do
|
15
15
|
option :location, :short => :l
|
16
16
|
end.parse(['-l', 'singapore'])
|
17
|
-
|
18
|
-
|
17
|
+
expect(ps.location).to be_a String
|
18
|
+
expect(ps.location).to eq 'singapore'
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should support casting" do
|
22
22
|
ps = CLI.new do
|
23
23
|
option :size, :cast => Integer
|
24
24
|
end.parse(['--size', '24'])
|
25
|
-
|
26
|
-
|
25
|
+
expect(ps.size).to be_a Integer
|
26
|
+
expect(ps.size).to eq 24
|
27
|
+
end
|
28
|
+
|
29
|
+
it "casting should fail if not proper integer given" do
|
30
|
+
expect {
|
31
|
+
ps = CLI.new do
|
32
|
+
option :size, :cast => Integer
|
33
|
+
end.parse(['--size', '24.99'])
|
34
|
+
}.to raise_error(CLI::ParsingError::CastError)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "casting should fail if not proper float given" do
|
38
|
+
expect {
|
39
|
+
ps = CLI.new do
|
40
|
+
option :size, :cast => Float
|
41
|
+
end.parse(['--size', '24.99x'])
|
42
|
+
}.to raise_error(CLI::ParsingError::CastError)
|
43
|
+
end
|
44
|
+
|
45
|
+
it "casting should fail if there is error in cast lambda" do
|
46
|
+
expect {
|
47
|
+
ps = CLI.new do
|
48
|
+
option :size, :cast => lambda{|v| fail 'test'}
|
49
|
+
end.parse(['--size', '24.99x'])
|
50
|
+
}.to raise_error(CLI::ParsingError::CastError)
|
27
51
|
end
|
28
52
|
|
29
53
|
it "should support casting of multiple options" do
|
30
54
|
ps = CLI.new do
|
31
55
|
options :size, :cast => Integer
|
32
56
|
end.parse(['--size', '24', '--size', '10'])
|
33
|
-
|
34
|
-
|
57
|
+
expect(ps.size).to be_a Array
|
58
|
+
expect(ps.size).to eq [24, 10]
|
35
59
|
end
|
36
60
|
|
37
61
|
it "should support casting of multiple options with default" do
|
@@ -39,22 +63,22 @@ describe CLI do
|
|
39
63
|
options :log_file, :cast => Pathname, :default => 'test.log'
|
40
64
|
end.parse(['--log-file', 'server.log', '--log-file', 'error.log'])
|
41
65
|
|
42
|
-
|
43
|
-
|
66
|
+
expect(ps.log_file).to be_a Array
|
67
|
+
expect(ps.log_file.length).to eq 2
|
44
68
|
|
45
|
-
|
46
|
-
|
69
|
+
expect(ps.log_file.first).to be_a Pathname
|
70
|
+
expect(ps.log_file.first.to_s).to eq 'server.log'
|
47
71
|
|
48
|
-
|
49
|
-
|
72
|
+
expect(ps.log_file.last).to be_a Pathname
|
73
|
+
expect(ps.log_file.last.to_s).to eq 'error.log'
|
50
74
|
end
|
51
75
|
|
52
76
|
it "should support casting with lambda" do
|
53
77
|
ps = CLI.new do
|
54
78
|
option :size, :cast => lambda{|v| v.to_i + 2}
|
55
79
|
end.parse(['--size', '24'])
|
56
|
-
|
57
|
-
|
80
|
+
expect(ps.size).to be_a Integer
|
81
|
+
expect(ps.size).to eq 26
|
58
82
|
end
|
59
83
|
|
60
84
|
it "should support casting with class" do
|
@@ -68,8 +92,8 @@ describe CLI do
|
|
68
92
|
ps = CLI.new do
|
69
93
|
option :text, :cast => Upcaser
|
70
94
|
end.parse(['--text', 'hello world'])
|
71
|
-
|
72
|
-
|
95
|
+
expect(ps.text).to be_a Upcaser
|
96
|
+
expect(ps.text.value).to eq 'HELLO WORLD'
|
73
97
|
end
|
74
98
|
|
75
99
|
it "should handle default values" do
|
@@ -77,36 +101,36 @@ describe CLI do
|
|
77
101
|
option :location, :default => 'singapore'
|
78
102
|
option :size, :cast => Integer, :default => 23
|
79
103
|
end.parse([])
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
104
|
+
expect(ps.location).to be_a String
|
105
|
+
expect(ps.location).to eq 'singapore'
|
106
|
+
expect(ps.size).to be_a Integer
|
107
|
+
expect(ps.size).to eq 23
|
84
108
|
end
|
85
109
|
|
86
110
|
it "default value is casted" do
|
87
111
|
ps = CLI.new do
|
88
112
|
option :location, :default => 'singapore'
|
89
|
-
option :size, :cast => Integer, :default => 23
|
113
|
+
option :size, :cast => Integer, :default => 23
|
90
114
|
end.parse([])
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
115
|
+
expect(ps.location).to be_a String
|
116
|
+
expect(ps.location).to eq 'singapore'
|
117
|
+
expect(ps.size).to be_a Integer
|
118
|
+
expect(ps.size).to eq 23
|
95
119
|
end
|
96
120
|
|
97
121
|
it "not given and not defined options should be nil" do
|
98
122
|
ps = CLI.new do
|
99
123
|
option :size, :cast => Integer
|
100
124
|
end.parse([])
|
101
|
-
|
102
|
-
|
125
|
+
expect(ps.size).to be_nil
|
126
|
+
expect(ps.gold).to be_nil
|
103
127
|
end
|
104
128
|
|
105
129
|
it "not given option that can be specified multiple times should be an empty array" do
|
106
130
|
ps = CLI.new do
|
107
131
|
options :size, :cast => Integer
|
108
132
|
end.parse([])
|
109
|
-
|
133
|
+
expect(ps.size).to eq []
|
110
134
|
end
|
111
135
|
|
112
136
|
it "should handle multiple long and short intermixed options" do
|
@@ -118,62 +142,62 @@ describe CLI do
|
|
118
142
|
option :not_given
|
119
143
|
option :size
|
120
144
|
end.parse(['-l', 'singapore', '--power-up', 'yes', '-s', '24', '--size', 'XXXL'])
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
145
|
+
expect(ps.group).to eq 'red'
|
146
|
+
expect(ps.power_up).to eq 'yes'
|
147
|
+
expect(ps.speed).to eq 24
|
148
|
+
expect(ps.not_given).to be_nil
|
149
|
+
expect(ps.size).to eq 'XXXL'
|
150
|
+
expect(ps.gold).to be_nil
|
127
151
|
end
|
128
152
|
|
129
153
|
it "should support options that can be specified multiple times" do
|
130
154
|
ps = CLI.new do
|
131
155
|
options :power_up, :short => :p
|
132
156
|
end.parse(['--power-up', 'fire'])
|
133
|
-
|
157
|
+
expect(ps.power_up).to eq ['fire']
|
134
158
|
|
135
159
|
ps = CLI.new do
|
136
160
|
options :power_up, :short => :p
|
137
161
|
end.parse(['--power-up', 'fire', '-p', 'water', '--power-up', 'air', '-p', 'ground'])
|
138
|
-
|
162
|
+
expect(ps.power_up).to eq ['fire', 'water', 'air', 'ground']
|
139
163
|
end
|
140
164
|
|
141
165
|
it "should support options that can be specified multiple times can have single default" do
|
142
166
|
ps = CLI.new do
|
143
167
|
options :power_up, :short => :p, :default => 'fire'
|
144
168
|
end.parse([])
|
145
|
-
|
169
|
+
expect(ps.power_up).to eq ['fire']
|
146
170
|
end
|
147
171
|
|
148
172
|
it "should support options that can be specified multiple times can have multiple defaults" do
|
149
173
|
ps = CLI.new do
|
150
174
|
options :power_up, :short => :p, :default => ['fire', 'air']
|
151
175
|
end.parse([])
|
152
|
-
|
176
|
+
expect(ps.power_up).to eq ['fire', 'air']
|
153
177
|
end
|
154
178
|
|
155
179
|
it "should raise error if not symbol and optional hash is passed" do
|
156
|
-
|
180
|
+
expect {
|
157
181
|
ps = CLI.new do
|
158
182
|
option 'number'
|
159
183
|
end
|
160
|
-
}.
|
184
|
+
}.to raise_error CLI::ParserError::NameArgumetNotSymbolError, "option name has to be of type Symbol, got String"
|
161
185
|
|
162
|
-
|
186
|
+
expect {
|
163
187
|
ps = CLI.new do
|
164
188
|
option :number, :test
|
165
189
|
end
|
166
|
-
}.
|
190
|
+
}.to raise_error CLI::ParserError::OptionsArgumentNotHashError, "option options has to be of type Hash, got Symbol"
|
167
191
|
end
|
168
192
|
|
169
193
|
it "should raise error on missing option argument" do
|
170
194
|
ps = CLI.new do
|
171
195
|
option :location
|
172
196
|
end
|
173
|
-
|
174
|
-
|
197
|
+
|
198
|
+
expect {
|
175
199
|
ps.parse(['--location'])
|
176
|
-
}.
|
200
|
+
}.to raise_error CLI::ParsingError::MissingOptionValueError, 'missing value for option --location'
|
177
201
|
end
|
178
202
|
|
179
203
|
it "should raise error on missing mandatory option" do
|
@@ -184,10 +208,10 @@ describe CLI do
|
|
184
208
|
option :group, :default => 'red'
|
185
209
|
option :speed, :short => :s, :cast => Integer
|
186
210
|
end
|
187
|
-
|
188
|
-
|
211
|
+
|
212
|
+
expect {
|
189
213
|
ps.parse([])
|
190
|
-
}.
|
214
|
+
}.to raise_error CLI::ParsingError::MandatoryOptionsNotSpecifiedError, "mandatory options not specified: --size, --weight"
|
191
215
|
end
|
192
216
|
|
193
217
|
it "by default option value should be nil" do
|
@@ -197,15 +221,14 @@ describe CLI do
|
|
197
221
|
option :weight, :required => true
|
198
222
|
option :group, :default => 'red'
|
199
223
|
end
|
200
|
-
|
224
|
+
|
201
225
|
o = ps.parse(['--weight', '123'])
|
202
226
|
|
203
|
-
|
204
|
-
|
227
|
+
expect(o.location).to be_nil
|
228
|
+
expect(o.speed).to be_nil
|
205
229
|
|
206
|
-
|
207
|
-
|
230
|
+
expect(o.weight).to eq '123'
|
231
|
+
expect(o.group).to eq 'red'
|
208
232
|
end
|
209
233
|
end
|
210
234
|
end
|
211
|
-
|
data/spec/separator_spec.rb
CHANGED
@@ -11,12 +11,12 @@ describe CLI do
|
|
11
11
|
argument :test
|
12
12
|
end.parse(['-l', 'singapore', '--debug', '--', '--verbose'])
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
14
|
+
expect(ps.help).to be_nil
|
15
|
+
expect(ps.location).to eq 'singapore'
|
16
|
+
expect(ps.group).to eq 'red'
|
17
|
+
expect(ps.debug).to be true
|
18
|
+
expect(ps.test).to eq '--verbose'
|
19
|
+
expect(ps.verbose).to be_nil
|
20
20
|
|
21
21
|
ps = CLI.new do
|
22
22
|
option :location, :short => :l
|
@@ -26,11 +26,11 @@ describe CLI do
|
|
26
26
|
argument :test
|
27
27
|
end.parse(['-l', 'singapore', '--debug', '--help'])
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
29
|
+
expect(ps.location).to be_nil
|
30
|
+
expect(ps.group).to be_nil
|
31
|
+
expect(ps.debug).to be_nil
|
32
|
+
expect(ps.verbose).to be_nil
|
33
|
+
expect(ps.help).not_to be_nil
|
34
34
|
|
35
35
|
ps = CLI.new do
|
36
36
|
option :location, :short => :l
|
@@ -43,15 +43,14 @@ describe CLI do
|
|
43
43
|
argument :test3
|
44
44
|
end.parse(['-l', 'singapore', '--debug', '--', '--help', '--version', '-m'])
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
46
|
+
expect(ps.help).to be_nil
|
47
|
+
expect(ps.location).to eq 'singapore'
|
48
|
+
expect(ps.group).to eq 'red'
|
49
|
+
expect(ps.debug).to be true
|
50
|
+
expect(ps.test).to eq '--help'
|
51
|
+
expect(ps.test2).to eq '--version'
|
52
|
+
expect(ps.test3).to eq '-m'
|
53
|
+
expect(ps.verbose).to be_nil
|
54
54
|
end
|
55
55
|
end
|
56
56
|
end
|
57
|
-
|
data/spec/stdin_spec.rb
CHANGED
@@ -5,23 +5,23 @@ describe CLI do
|
|
5
5
|
describe 'STDIN handling' do
|
6
6
|
before :all do
|
7
7
|
@yaml = <<EOF
|
8
|
-
---
|
9
|
-
:parser:
|
8
|
+
---
|
9
|
+
:parser:
|
10
10
|
:successes: 41
|
11
11
|
:failures: 0
|
12
12
|
EOF
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should be nil if not specified" do
|
16
|
-
ps = CLI.new.parse
|
17
|
-
|
16
|
+
ps = CLI.new.parse([])
|
17
|
+
expect(ps.stdin).to be_nil
|
18
18
|
end
|
19
19
|
|
20
20
|
it "should return IO if stdin is defined" do
|
21
21
|
ps = CLI.new do
|
22
22
|
stdin
|
23
|
-
end.parse
|
24
|
-
|
23
|
+
end.parse([])
|
24
|
+
expect(ps.stdin).to be_a IO
|
25
25
|
end
|
26
26
|
|
27
27
|
it "should support casting to module responding to load" do
|
@@ -31,10 +31,10 @@ EOF
|
|
31
31
|
end
|
32
32
|
|
33
33
|
stdin_write(@yaml) do
|
34
|
-
ps = ss.parse
|
34
|
+
ps = ss.parse([])
|
35
35
|
end
|
36
36
|
|
37
|
-
|
37
|
+
expect(ps.stdin).to eq({:parser=>{:successes=>41, :failures=>0}})
|
38
38
|
end
|
39
39
|
|
40
40
|
it "should support casting with lambda" do
|
@@ -44,10 +44,10 @@ EOF
|
|
44
44
|
end
|
45
45
|
|
46
46
|
stdin_write('hello world') do
|
47
|
-
ps = ss.parse
|
47
|
+
ps = ss.parse([])
|
48
48
|
end
|
49
49
|
|
50
|
-
|
50
|
+
expect(ps.stdin).to eq 'HELLO WORLD'
|
51
51
|
end
|
52
52
|
|
53
53
|
it "should support casting with custom class" do
|
@@ -64,12 +64,11 @@ EOF
|
|
64
64
|
end
|
65
65
|
|
66
66
|
stdin_write('hello world') do
|
67
|
-
ps = ss.parse
|
67
|
+
ps = ss.parse([])
|
68
68
|
end
|
69
69
|
|
70
|
-
|
71
|
-
|
70
|
+
expect(ps.stdin).to be_a Upcaser
|
71
|
+
expect(ps.stdin.value).to eq 'HELLO WORLD'
|
72
72
|
end
|
73
73
|
end
|
74
74
|
end
|
75
|
-
|
data/spec/switch_spec.rb
CHANGED
@@ -7,8 +7,8 @@ describe CLI do
|
|
7
7
|
switch :location
|
8
8
|
switch :unset
|
9
9
|
end.parse(['--location'])
|
10
|
-
|
11
|
-
|
10
|
+
expect(ps.location).to be true
|
11
|
+
expect(ps.unset).to be_nil
|
12
12
|
end
|
13
13
|
|
14
14
|
it "should handle short switch names" do
|
@@ -16,47 +16,46 @@ describe CLI do
|
|
16
16
|
switch :location, :short => :l
|
17
17
|
switch :unset, :short => :u
|
18
18
|
end.parse(['-l'])
|
19
|
-
|
20
|
-
|
19
|
+
expect(ps.location).to be true
|
20
|
+
expect(ps.unset).to be_nil
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should raise error if not symbol and optional hash is passed" do
|
24
|
-
|
24
|
+
expect {
|
25
25
|
ps = CLI.new do
|
26
26
|
switch 'number'
|
27
27
|
end.parse([])
|
28
|
-
}.
|
28
|
+
}.to raise_error CLI::ParserError::NameArgumetNotSymbolError, "switch name has to be of type Symbol, got String"
|
29
29
|
|
30
|
-
|
30
|
+
expect {
|
31
31
|
ps = CLI.new do
|
32
32
|
switch :number, :test
|
33
33
|
end
|
34
|
-
}.
|
34
|
+
}.to raise_error CLI::ParserError::OptionsArgumentNotHashError, "switch options has to be of type Hash, got Symbol"
|
35
35
|
end
|
36
36
|
|
37
37
|
it "shoud raise error is short name is invalid" do
|
38
|
-
|
38
|
+
expect {
|
39
39
|
ps = CLI.new do
|
40
40
|
switch :location, :short => "l"
|
41
41
|
end
|
42
|
-
}.
|
42
|
+
}.to raise_error CLI::ParserError::ShortNameNotSymbolError, 'short name for --location has to be of type Symbol, got String'
|
43
43
|
|
44
|
-
|
44
|
+
expect {
|
45
45
|
ps = CLI.new do
|
46
46
|
switch :location, :short => :abc
|
47
47
|
end
|
48
|
-
}.
|
48
|
+
}.to raise_error CLI::ParserError::ShortNameIsInvalidError, 'short name for --location has to be one letter symbol, got :abc'
|
49
49
|
end
|
50
50
|
|
51
51
|
it "should raise error on unrecognized switch" do
|
52
52
|
ps = CLI.new do
|
53
53
|
option :location
|
54
54
|
end
|
55
|
-
|
56
|
-
|
55
|
+
|
56
|
+
expect {
|
57
57
|
ps.parse(['--xxx'])
|
58
|
-
}.
|
58
|
+
}.to raise_error CLI::ParsingError::UnknownSwitchError, 'unknown switch --xxx'
|
59
59
|
end
|
60
60
|
end
|
61
61
|
end
|
62
|
-
|