cooloptions 1.1.0 → 1.1.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/History.txt +5 -0
- data/README.txt +14 -3
- data/lib/cooloptions.rb +6 -2
- data/test/test_cooloptions.rb +13 -0
- metadata +8 -7
data/History.txt
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
== 1.1.1 / 2007-03-09
|
2
|
+
|
3
|
+
* Better handling of OptionParser::ParseError [Christian von Mueffling].
|
4
|
+
* A few small documentation tweaks, including an updated copyright.
|
5
|
+
|
1
6
|
== 1.1.0 / 2007-01-10
|
2
7
|
|
3
8
|
* Incremented the version number to more rationally reflect the addition of
|
data/README.txt
CHANGED
@@ -2,11 +2,17 @@
|
|
2
2
|
by Nathaniel Talbott <nathaniel@terralien.com>
|
3
3
|
http://cooloptions.rubyforge.org/
|
4
4
|
|
5
|
+
|
5
6
|
== DESCRIPTION:
|
6
7
|
|
7
|
-
CoolOptions is a simple wrapper around optparse that provides less options and
|
8
|
+
CoolOptions is a simple wrapper around optparse that provides less options and
|
9
|
+
more convenience.
|
10
|
+
|
11
|
+
As a huge fan of optparse due to its flexibility, self-documenting nature, and
|
12
|
+
ease of use, I nevertheless found myself doing almost the exact same thing
|
13
|
+
with it over and over again, and decided to write a thin wrapper around it to
|
14
|
+
handle the common cases. Thus CoolOptions was born.
|
8
15
|
|
9
|
-
As a huge fan of optparse due to its flexibility, self-documenting nature, and ease of use, I nevertheless found myself doing almost the exact same thing with it over and over again, and decided to write a thin wrapper around it to handle the common cases. Thus CoolOptions was born.
|
10
16
|
|
11
17
|
== SYNOPSIS:
|
12
18
|
|
@@ -65,26 +71,31 @@ As a huge fan of optparse due to its flexibility, self-documenting nature, and e
|
|
65
71
|
Default is: true
|
66
72
|
-h, --help This help info.
|
67
73
|
|
74
|
+
|
68
75
|
== REQUIREMENTS:
|
69
76
|
|
70
77
|
optparse & ostruct (included in Ruby standard library).
|
71
78
|
|
79
|
+
|
72
80
|
== DOWNLOAD:
|
73
81
|
|
74
82
|
Via gems or from the
|
75
83
|
{Rubyforge project page}[http://rubyforge.org/projects/cooloptions].
|
76
84
|
|
85
|
+
|
77
86
|
== INSTALL:
|
78
87
|
|
79
88
|
sudo gem install cooloptions
|
80
89
|
|
90
|
+
|
81
91
|
== CONTRIBUTE:
|
82
92
|
|
83
93
|
Drop me an email (see above) and/or
|
84
94
|
{check out the source}[http://terralien.com/svn/projects/cooloptions/trunk].
|
85
95
|
|
96
|
+
|
86
97
|
== LICENSE:
|
87
98
|
|
88
99
|
The RUBY License
|
89
100
|
|
90
|
-
Copyright (c) 2006 Nathaniel Talbott and Terralien, Inc. All Rights Reserved.
|
101
|
+
Copyright (c) 2006-2007 Nathaniel Talbott and Terralien, Inc. All Rights Reserved.
|
data/lib/cooloptions.rb
CHANGED
@@ -11,7 +11,7 @@ require 'ostruct'
|
|
11
11
|
# :include:samples/literate.rb
|
12
12
|
|
13
13
|
class CoolOptions
|
14
|
-
VERSION = '1.1.
|
14
|
+
VERSION = '1.1.1' #:nodoc:
|
15
15
|
|
16
16
|
class Error < StandardError #:nodoc:
|
17
17
|
end
|
@@ -97,7 +97,11 @@ class CoolOptions
|
|
97
97
|
|
98
98
|
def parse!(argv) #:nodoc:
|
99
99
|
@parser.on('-h', '--help', "This help info."){help}
|
100
|
-
|
100
|
+
begin
|
101
|
+
@parser.parse!(argv)
|
102
|
+
rescue OptionParser::ParseError => e
|
103
|
+
error e.message.capitalize
|
104
|
+
end
|
101
105
|
|
102
106
|
@required.reject!{|e| @result.key?(e)}
|
103
107
|
error "Missing required options: #{@required.join(', ')}" unless @required.empty?
|
data/test/test_cooloptions.rb
CHANGED
@@ -157,4 +157,17 @@ EOH
|
|
157
157
|
|
158
158
|
assert 'd', r.cl
|
159
159
|
end
|
160
|
+
|
161
|
+
def test_should_show_nice_error_for_bogus_option
|
162
|
+
assert_raise(SystemExit) do
|
163
|
+
CoolOptions.parse!('details', ['--bogus']) do |o|
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
assert_equal <<EOH, @out.string
|
168
|
+
Invalid option: --bogus
|
169
|
+
Usage: #{File.basename($0)} details
|
170
|
+
-h, --help This help info.
|
171
|
+
EOH
|
172
|
+
end
|
160
173
|
end
|
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.
|
2
|
+
rubygems_version: 0.9.2
|
3
3
|
specification_version: 1
|
4
4
|
name: cooloptions
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.1.
|
7
|
-
date: 2007-
|
6
|
+
version: 1.1.1
|
7
|
+
date: 2007-03-09 00:00:00 -05:00
|
8
8
|
summary: CoolOptions is a simple wrapper around optparse that provides less configuration and more convenience for doing command-line option handling.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -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
|
- Nathaniel Talbott
|
30
31
|
files:
|
@@ -50,20 +51,20 @@ requirements: []
|
|
50
51
|
|
51
52
|
dependencies:
|
52
53
|
- !ruby/object:Gem::Dependency
|
53
|
-
name:
|
54
|
+
name: rake
|
54
55
|
version_requirement:
|
55
56
|
version_requirements: !ruby/object:Gem::Version::Requirement
|
56
57
|
requirements:
|
57
58
|
- - ">="
|
58
59
|
- !ruby/object:Gem::Version
|
59
|
-
version:
|
60
|
+
version: 0.7.1
|
60
61
|
version:
|
61
62
|
- !ruby/object:Gem::Dependency
|
62
|
-
name:
|
63
|
+
name: hoe
|
63
64
|
version_requirement:
|
64
65
|
version_requirements: !ruby/object:Gem::Version::Requirement
|
65
66
|
requirements:
|
66
67
|
- - ">="
|
67
68
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
69
|
+
version: 1.2.0
|
69
70
|
version:
|