cli 1.3.1 → 1.4.0
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.
- checksums.yaml +7 -0
- data/Gemfile +5 -7
- data/Gemfile.lock +29 -37
- data/README.md +17 -18
- data/Rakefile +1 -28
- data/cli.gemspec +14 -84
- 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 +104 -105
- data/spec/cli_spec.rb +27 -28
- data/spec/conflict_reporting_spec.rb +16 -17
- data/spec/option_spec.rb +60 -61
- 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 -139
- 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,56 +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
27
|
end
|
28
28
|
|
29
29
|
it "casting should fail if not proper integer given" do
|
30
|
-
|
30
|
+
expect {
|
31
31
|
ps = CLI.new do
|
32
32
|
option :size, :cast => Integer
|
33
33
|
end.parse(['--size', '24.99'])
|
34
|
-
}.
|
34
|
+
}.to raise_error(CLI::ParsingError::CastError)
|
35
35
|
end
|
36
36
|
|
37
37
|
it "casting should fail if not proper float given" do
|
38
|
-
|
38
|
+
expect {
|
39
39
|
ps = CLI.new do
|
40
40
|
option :size, :cast => Float
|
41
41
|
end.parse(['--size', '24.99x'])
|
42
|
-
}.
|
42
|
+
}.to raise_error(CLI::ParsingError::CastError)
|
43
43
|
end
|
44
44
|
|
45
45
|
it "casting should fail if there is error in cast lambda" do
|
46
|
-
|
46
|
+
expect {
|
47
47
|
ps = CLI.new do
|
48
48
|
option :size, :cast => lambda{|v| fail 'test'}
|
49
49
|
end.parse(['--size', '24.99x'])
|
50
|
-
}.
|
50
|
+
}.to raise_error(CLI::ParsingError::CastError)
|
51
51
|
end
|
52
52
|
|
53
53
|
it "should support casting of multiple options" do
|
54
54
|
ps = CLI.new do
|
55
55
|
options :size, :cast => Integer
|
56
56
|
end.parse(['--size', '24', '--size', '10'])
|
57
|
-
|
58
|
-
|
57
|
+
expect(ps.size).to be_a Array
|
58
|
+
expect(ps.size).to eq [24, 10]
|
59
59
|
end
|
60
60
|
|
61
61
|
it "should support casting of multiple options with default" do
|
@@ -63,22 +63,22 @@ describe CLI do
|
|
63
63
|
options :log_file, :cast => Pathname, :default => 'test.log'
|
64
64
|
end.parse(['--log-file', 'server.log', '--log-file', 'error.log'])
|
65
65
|
|
66
|
-
|
67
|
-
|
66
|
+
expect(ps.log_file).to be_a Array
|
67
|
+
expect(ps.log_file.length).to eq 2
|
68
68
|
|
69
|
-
|
70
|
-
|
69
|
+
expect(ps.log_file.first).to be_a Pathname
|
70
|
+
expect(ps.log_file.first.to_s).to eq 'server.log'
|
71
71
|
|
72
|
-
|
73
|
-
|
72
|
+
expect(ps.log_file.last).to be_a Pathname
|
73
|
+
expect(ps.log_file.last.to_s).to eq 'error.log'
|
74
74
|
end
|
75
75
|
|
76
76
|
it "should support casting with lambda" do
|
77
77
|
ps = CLI.new do
|
78
78
|
option :size, :cast => lambda{|v| v.to_i + 2}
|
79
79
|
end.parse(['--size', '24'])
|
80
|
-
|
81
|
-
|
80
|
+
expect(ps.size).to be_a Integer
|
81
|
+
expect(ps.size).to eq 26
|
82
82
|
end
|
83
83
|
|
84
84
|
it "should support casting with class" do
|
@@ -92,8 +92,8 @@ describe CLI do
|
|
92
92
|
ps = CLI.new do
|
93
93
|
option :text, :cast => Upcaser
|
94
94
|
end.parse(['--text', 'hello world'])
|
95
|
-
|
96
|
-
|
95
|
+
expect(ps.text).to be_a Upcaser
|
96
|
+
expect(ps.text.value).to eq 'HELLO WORLD'
|
97
97
|
end
|
98
98
|
|
99
99
|
it "should handle default values" do
|
@@ -101,10 +101,10 @@ describe CLI do
|
|
101
101
|
option :location, :default => 'singapore'
|
102
102
|
option :size, :cast => Integer, :default => 23
|
103
103
|
end.parse([])
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
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
|
108
108
|
end
|
109
109
|
|
110
110
|
it "default value is casted" do
|
@@ -112,25 +112,25 @@ describe CLI do
|
|
112
112
|
option :location, :default => 'singapore'
|
113
113
|
option :size, :cast => Integer, :default => 23
|
114
114
|
end.parse([])
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
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
|
119
119
|
end
|
120
120
|
|
121
121
|
it "not given and not defined options should be nil" do
|
122
122
|
ps = CLI.new do
|
123
123
|
option :size, :cast => Integer
|
124
124
|
end.parse([])
|
125
|
-
|
126
|
-
|
125
|
+
expect(ps.size).to be_nil
|
126
|
+
expect(ps.gold).to be_nil
|
127
127
|
end
|
128
128
|
|
129
129
|
it "not given option that can be specified multiple times should be an empty array" do
|
130
130
|
ps = CLI.new do
|
131
131
|
options :size, :cast => Integer
|
132
132
|
end.parse([])
|
133
|
-
|
133
|
+
expect(ps.size).to eq []
|
134
134
|
end
|
135
135
|
|
136
136
|
it "should handle multiple long and short intermixed options" do
|
@@ -142,62 +142,62 @@ describe CLI do
|
|
142
142
|
option :not_given
|
143
143
|
option :size
|
144
144
|
end.parse(['-l', 'singapore', '--power-up', 'yes', '-s', '24', '--size', 'XXXL'])
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
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
|
151
151
|
end
|
152
152
|
|
153
153
|
it "should support options that can be specified multiple times" do
|
154
154
|
ps = CLI.new do
|
155
155
|
options :power_up, :short => :p
|
156
156
|
end.parse(['--power-up', 'fire'])
|
157
|
-
|
157
|
+
expect(ps.power_up).to eq ['fire']
|
158
158
|
|
159
159
|
ps = CLI.new do
|
160
160
|
options :power_up, :short => :p
|
161
161
|
end.parse(['--power-up', 'fire', '-p', 'water', '--power-up', 'air', '-p', 'ground'])
|
162
|
-
|
162
|
+
expect(ps.power_up).to eq ['fire', 'water', 'air', 'ground']
|
163
163
|
end
|
164
164
|
|
165
165
|
it "should support options that can be specified multiple times can have single default" do
|
166
166
|
ps = CLI.new do
|
167
167
|
options :power_up, :short => :p, :default => 'fire'
|
168
168
|
end.parse([])
|
169
|
-
|
169
|
+
expect(ps.power_up).to eq ['fire']
|
170
170
|
end
|
171
171
|
|
172
172
|
it "should support options that can be specified multiple times can have multiple defaults" do
|
173
173
|
ps = CLI.new do
|
174
174
|
options :power_up, :short => :p, :default => ['fire', 'air']
|
175
175
|
end.parse([])
|
176
|
-
|
176
|
+
expect(ps.power_up).to eq ['fire', 'air']
|
177
177
|
end
|
178
178
|
|
179
179
|
it "should raise error if not symbol and optional hash is passed" do
|
180
|
-
|
180
|
+
expect {
|
181
181
|
ps = CLI.new do
|
182
182
|
option 'number'
|
183
183
|
end
|
184
|
-
}.
|
184
|
+
}.to raise_error CLI::ParserError::NameArgumetNotSymbolError, "option name has to be of type Symbol, got String"
|
185
185
|
|
186
|
-
|
186
|
+
expect {
|
187
187
|
ps = CLI.new do
|
188
188
|
option :number, :test
|
189
189
|
end
|
190
|
-
}.
|
190
|
+
}.to raise_error CLI::ParserError::OptionsArgumentNotHashError, "option options has to be of type Hash, got Symbol"
|
191
191
|
end
|
192
192
|
|
193
193
|
it "should raise error on missing option argument" do
|
194
194
|
ps = CLI.new do
|
195
195
|
option :location
|
196
196
|
end
|
197
|
-
|
198
|
-
|
197
|
+
|
198
|
+
expect {
|
199
199
|
ps.parse(['--location'])
|
200
|
-
}.
|
200
|
+
}.to raise_error CLI::ParsingError::MissingOptionValueError, 'missing value for option --location'
|
201
201
|
end
|
202
202
|
|
203
203
|
it "should raise error on missing mandatory option" do
|
@@ -208,10 +208,10 @@ describe CLI do
|
|
208
208
|
option :group, :default => 'red'
|
209
209
|
option :speed, :short => :s, :cast => Integer
|
210
210
|
end
|
211
|
-
|
212
|
-
|
211
|
+
|
212
|
+
expect {
|
213
213
|
ps.parse([])
|
214
|
-
}.
|
214
|
+
}.to raise_error CLI::ParsingError::MandatoryOptionsNotSpecifiedError, "mandatory options not specified: --size, --weight"
|
215
215
|
end
|
216
216
|
|
217
217
|
it "by default option value should be nil" do
|
@@ -221,15 +221,14 @@ describe CLI do
|
|
221
221
|
option :weight, :required => true
|
222
222
|
option :group, :default => 'red'
|
223
223
|
end
|
224
|
-
|
224
|
+
|
225
225
|
o = ps.parse(['--weight', '123'])
|
226
226
|
|
227
|
-
|
228
|
-
|
227
|
+
expect(o.location).to be_nil
|
228
|
+
expect(o.speed).to be_nil
|
229
229
|
|
230
|
-
|
231
|
-
|
230
|
+
expect(o.weight).to eq '123'
|
231
|
+
expect(o.group).to eq 'red'
|
232
232
|
end
|
233
233
|
end
|
234
234
|
end
|
235
|
-
|
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
|
-
|