trollop 1.6 → 1.7
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/Rakefile +1 -1
- data/lib/trollop.rb +4 -2
- data/test/test_trollop.rb +21 -0
- metadata +5 -4
data/History.txt
CHANGED
data/Rakefile
CHANGED
@@ -11,7 +11,7 @@ end # thanks to "Mike H"
|
|
11
11
|
Hoe.new('trollop', Trollop::VERSION) do |p|
|
12
12
|
p.rubyforge_name = 'trollop'
|
13
13
|
p.author = "William Morgan"
|
14
|
-
p.summary = "
|
14
|
+
p.summary = "YAFCLAP --- yet another fine commandline argument processing library for Ruby. Trollop is designed to provide the maximal amount of GNU-style argument processing in the minimum number of lines of code (for you, the programmer)."
|
15
15
|
|
16
16
|
p.description = p.paragraphs_of('README.txt', 4..5, 9..18).join("\n\n").gsub(/== SYNOPSIS/, "Synopsis")
|
17
17
|
p.url = "http://trollop.rubyforge.org"
|
data/lib/trollop.rb
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
module Trollop
|
7
7
|
|
8
|
-
VERSION = "1.
|
8
|
+
VERSION = "1.7"
|
9
9
|
|
10
10
|
## Thrown by Parser in the event of a commandline error. Not needed if
|
11
11
|
## you're using the Trollop::options entry.
|
@@ -275,7 +275,9 @@ class Parser
|
|
275
275
|
end
|
276
276
|
end
|
277
277
|
|
278
|
-
|
278
|
+
required.each do |sym, val|
|
279
|
+
raise CommandlineError, "option '#{sym}' must be specified" unless found[sym]
|
280
|
+
end
|
279
281
|
|
280
282
|
## parse parameters
|
281
283
|
args.each do |sym, arg, param|
|
data/test/test_trollop.rb
CHANGED
@@ -442,6 +442,27 @@ EOM
|
|
442
442
|
assert_raises(CommandlineError) { opts = @p.parse %w(--mellow --two --jello --one) }
|
443
443
|
end
|
444
444
|
|
445
|
+
## courtesy neill zero
|
446
|
+
def test_two_required_one_missing_accuses_correctly
|
447
|
+
@p.opt "arg1", "desc1", :required => true
|
448
|
+
@p.opt "arg2", "desc2", :required => true
|
449
|
+
|
450
|
+
begin
|
451
|
+
@p.parse(%w(--arg1))
|
452
|
+
flunk "should have failed on a missing req"
|
453
|
+
rescue CommandlineError => e
|
454
|
+
assert e.message =~ /arg2/, "didn't mention arg2 in the error msg: #{e.message}"
|
455
|
+
end
|
456
|
+
|
457
|
+
begin
|
458
|
+
@p.parse(%w(--arg2))
|
459
|
+
flunk "should have failed on a missing req"
|
460
|
+
rescue CommandlineError => e
|
461
|
+
assert e.message =~ /arg1/, "didn't mention arg1 in the error msg: #{e.message}"
|
462
|
+
end
|
463
|
+
|
464
|
+
assert_nothing_raised { @p.parse(%w(--arg1 --arg2)) }
|
465
|
+
end
|
445
466
|
end
|
446
467
|
|
447
468
|
end
|
metadata
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.
|
2
|
+
rubygems_version: 0.9.0
|
3
3
|
specification_version: 1
|
4
4
|
name: trollop
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: "1.
|
7
|
-
date: 2007-
|
8
|
-
summary:
|
6
|
+
version: "1.7"
|
7
|
+
date: 2007-06-17 00:00:00 -07:00
|
8
|
+
summary: YAFCLAP --- yet another fine commandline argument processing library for Ruby. Trollop is designed to provide the maximal amount of GNU-style argument processing in the minimum number of lines of code (for you, the programmer).
|
9
9
|
require_paths:
|
10
10
|
- lib
|
11
11
|
email: wmorgan-trollop@masanjin.net
|
@@ -25,6 +25,7 @@ required_ruby_version: !ruby/object:Gem::Version::Requirement
|
|
25
25
|
platform: ruby
|
26
26
|
signing_key:
|
27
27
|
cert_chain:
|
28
|
+
post_install_message:
|
28
29
|
authors:
|
29
30
|
- William Morgan
|
30
31
|
files:
|