optimist 3.1.0 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +1 -1
- data/.github/workflows/ci.yaml +3 -1
- data/CHANGELOG.md +222 -2
- data/examples/a_basic_example.rb +10 -0
- data/examples/alt_names.rb +20 -0
- data/examples/banners1.rb +11 -0
- data/examples/banners2.rb +12 -0
- data/examples/banners3.rb +14 -0
- data/examples/constraints.rb +28 -0
- data/examples/didyoumean.rb +26 -0
- data/examples/medium_example.rb +15 -0
- data/examples/partialmatch.rb +18 -0
- data/examples/permitted.rb +29 -0
- data/examples/types_custom.rb +43 -0
- data/lib/optimist.rb +347 -93
- data/optimist.gemspec +1 -1
- data/renovate.json +6 -0
- data/test/optimist/alt_names_test.rb +168 -0
- data/test/optimist/command_line_error_test.rb +1 -1
- data/test/optimist/help_needed_test.rb +1 -1
- data/test/optimist/parser_constraint_test.rb +141 -0
- data/test/optimist/parser_educate_test.rb +22 -1
- data/test/optimist/parser_opt_test.rb +1 -1
- data/test/optimist/parser_parse_test.rb +3 -3
- data/test/optimist/parser_permitted_test.rb +121 -0
- data/test/optimist/parser_test.rb +277 -176
- data/test/optimist/version_needed_test.rb +1 -1
- data/test/optimist_test.rb +5 -3
- data/test/support/assert_helpers.rb +6 -0
- metadata +22 -5
- data/History.txt +0 -175
data/test/optimist_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
class OptimistTest <
|
3
|
+
class OptimistTest < Minitest::Test
|
4
4
|
def setup
|
5
5
|
Optimist.send(:instance_variable_set, "@last_parser", nil)
|
6
6
|
end
|
@@ -39,7 +39,8 @@ class OptimistTest < MiniTest::Test
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def test_die_without_options_ever_run
|
42
|
-
|
42
|
+
err_regex = /Optimist::die can only be called after Optimist::options/
|
43
|
+
assert_raises_errmatch(ArgumentError, err_regex) { Optimist.die 'hello' }
|
43
44
|
end
|
44
45
|
|
45
46
|
def test_die
|
@@ -70,7 +71,8 @@ class OptimistTest < MiniTest::Test
|
|
70
71
|
end
|
71
72
|
|
72
73
|
def test_educate_without_options_ever_run
|
73
|
-
|
74
|
+
err_regex = /Optimist::educate can only be called after Optimist::options/
|
75
|
+
assert_raises_errmatch(ArgumentError, err_regex) { Optimist.educate }
|
74
76
|
end
|
75
77
|
|
76
78
|
def test_educate
|
@@ -42,5 +42,11 @@ module Minitest::Assertions
|
|
42
42
|
end
|
43
43
|
flunk "#{msg}#{mu_pp(exp)} SystemExit expected but nothing was raised."
|
44
44
|
end
|
45
|
+
|
46
|
+
# wrapper around common assertion checking pattern
|
47
|
+
def assert_raises_errmatch(err_klass, err_regexp, &b)
|
48
|
+
err = assert_raises(err_klass, &b)
|
49
|
+
assert_match(err_regexp, err.message)
|
50
|
+
end
|
45
51
|
end
|
46
52
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: optimist
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- William Morgan
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2024-11-11 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: chronic
|
@@ -89,17 +89,31 @@ files:
|
|
89
89
|
- CHANGELOG.md
|
90
90
|
- FAQ.txt
|
91
91
|
- Gemfile
|
92
|
-
- History.txt
|
93
92
|
- LICENSE.txt
|
94
93
|
- README.md
|
95
94
|
- Rakefile
|
95
|
+
- examples/a_basic_example.rb
|
96
|
+
- examples/alt_names.rb
|
97
|
+
- examples/banners1.rb
|
98
|
+
- examples/banners2.rb
|
99
|
+
- examples/banners3.rb
|
100
|
+
- examples/constraints.rb
|
101
|
+
- examples/didyoumean.rb
|
102
|
+
- examples/medium_example.rb
|
103
|
+
- examples/partialmatch.rb
|
104
|
+
- examples/permitted.rb
|
105
|
+
- examples/types_custom.rb
|
96
106
|
- lib/optimist.rb
|
97
107
|
- optimist.gemspec
|
108
|
+
- renovate.json
|
109
|
+
- test/optimist/alt_names_test.rb
|
98
110
|
- test/optimist/command_line_error_test.rb
|
99
111
|
- test/optimist/help_needed_test.rb
|
112
|
+
- test/optimist/parser_constraint_test.rb
|
100
113
|
- test/optimist/parser_educate_test.rb
|
101
114
|
- test/optimist/parser_opt_test.rb
|
102
115
|
- test/optimist/parser_parse_test.rb
|
116
|
+
- test/optimist/parser_permitted_test.rb
|
103
117
|
- test/optimist/parser_test.rb
|
104
118
|
- test/optimist/version_needed_test.rb
|
105
119
|
- test/optimist_test.rb
|
@@ -109,7 +123,7 @@ homepage: http://manageiq.github.io/optimist/
|
|
109
123
|
licenses:
|
110
124
|
- MIT
|
111
125
|
metadata:
|
112
|
-
changelog_uri: https://github.com/ManageIQ/optimist/blob/master/
|
126
|
+
changelog_uri: https://github.com/ManageIQ/optimist/blob/master/CHANGELOG.md
|
113
127
|
source_code_uri: https://github.com/ManageIQ/optimist/
|
114
128
|
bug_tracker_uri: https://github.com/ManageIQ/optimist/issues
|
115
129
|
post_install_message:
|
@@ -127,17 +141,20 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
141
|
- !ruby/object:Gem::Version
|
128
142
|
version: '0'
|
129
143
|
requirements: []
|
130
|
-
rubygems_version: 3.
|
144
|
+
rubygems_version: 3.3.27
|
131
145
|
signing_key:
|
132
146
|
specification_version: 4
|
133
147
|
summary: Optimist is a commandline option parser for Ruby that just gets out of your
|
134
148
|
way.
|
135
149
|
test_files:
|
150
|
+
- test/optimist/alt_names_test.rb
|
136
151
|
- test/optimist/command_line_error_test.rb
|
137
152
|
- test/optimist/help_needed_test.rb
|
153
|
+
- test/optimist/parser_constraint_test.rb
|
138
154
|
- test/optimist/parser_educate_test.rb
|
139
155
|
- test/optimist/parser_opt_test.rb
|
140
156
|
- test/optimist/parser_parse_test.rb
|
157
|
+
- test/optimist/parser_permitted_test.rb
|
141
158
|
- test/optimist/parser_test.rb
|
142
159
|
- test/optimist/version_needed_test.rb
|
143
160
|
- test/optimist_test.rb
|
data/History.txt
DELETED
@@ -1,175 +0,0 @@
|
|
1
|
-
== [3.0.1] / 2020-04-20
|
2
|
-
|
3
|
-
* Add a LICENSE.txt file to the released package
|
4
|
-
* Test fixes (thanks @aried3r, @neontapir, @npras)
|
5
|
-
|
6
|
-
== [3.0.0] / 2018-08-24
|
7
|
-
|
8
|
-
* The gem has been officially renamed to optimist
|
9
|
-
|
10
|
-
== [2.1.3] / 2018-07-05
|
11
|
-
|
12
|
-
* Refactor each option type into subclasses of Option. Define a registry for the registration of each option. This makes the code more modular and facilitates extension by allowing additional Option subclasses. (thanks @clxy)
|
13
|
-
* Fixed implementation of ignore_invalid_options. (thanks @metcalf)
|
14
|
-
* Various warning cleanup for ruby 2.1, 2.3, etc. (thanks @nanobowers)
|
15
|
-
* Optimist.die can now accept an error code.
|
16
|
-
* fixed default (thanks @nanobowers)
|
17
|
-
* Change from ruby license to MIT license in the code.
|
18
|
-
|
19
|
-
== [2.1.2] / 2015-03-10
|
20
|
-
* loosen mime-types requirements (for better ruby 1.8.7 support)
|
21
|
-
* use io/console gem instead of curses (for better jruby support)
|
22
|
-
* fix parsing bug when chronic gem is not available
|
23
|
-
* allow default array to be empty if a type is specified
|
24
|
-
* better specified license and better spec coverage
|
25
|
-
|
26
|
-
== [2.1.1] / 2015-01-03
|
27
|
-
* Remove curses as a hard dependency. It is optional. This can leverage the gem if it is present.
|
28
|
-
* Fix ruby -w warnings
|
29
|
-
|
30
|
-
== 2.1.0 / 2015-01-02
|
31
|
-
* Integer parser now supports underscore separator.
|
32
|
-
* Add Parser#usage and Parser#synopsis commands for creating a standard banner
|
33
|
-
message. Using Parser#banner directly will override both of those.
|
34
|
-
* Add Parser#ignore_invalid_options to prevent erroring on unknown options.
|
35
|
-
* Allow flags to act as switches if they have defaults set and no value is
|
36
|
-
passed on the commandline
|
37
|
-
* Parser#opt learned to accept a block or a :callback option which it will call
|
38
|
-
after parsing the option.
|
39
|
-
* Add Optimist::educate which displays the help message and dies.
|
40
|
-
* Reformat help message to be more GNUish.
|
41
|
-
* Fix command name in help message when script has no extension.
|
42
|
-
* Fix handling of newlines inside descriptions
|
43
|
-
* Documentation and other fixes.
|
44
|
-
|
45
|
-
== 2.0 / 2012-08-11
|
46
|
-
* Change flag logic: --no-X will always be false, and --X will always be true,
|
47
|
-
regardless of default.
|
48
|
-
* For flags that default to true, display --no-X instead of --X in the help
|
49
|
-
menu. Accept both versions on the commandline.
|
50
|
-
* Fix a spurious warning
|
51
|
-
* Update Rakefile to 1.9
|
52
|
-
* Minor documentation fixes
|
53
|
-
|
54
|
-
== 1.16.2 / 2010-04-06
|
55
|
-
* Bugfix in Optimist::options. Thanks to Brian C. Thomas for pointing it out.
|
56
|
-
|
57
|
-
== 1.16.1 / 2010-04-05
|
58
|
-
* Bugfix in Optimist::die method introduced in last release.
|
59
|
-
|
60
|
-
== 1.16 / 2010-04-01
|
61
|
-
* Add Optimist::with_standard_exception_handling method for easing the use of Parser directly.
|
62
|
-
* Handle scientific notation in float arguments, thanks to Will Fitzgerald.
|
63
|
-
* Drop hoe dependency.
|
64
|
-
|
65
|
-
== 1.15 / 2009-09-30
|
66
|
-
* Don't raise an exception when out of short arguments (thanks to Rafael
|
67
|
-
Sevilla for pointing out how dumb this behavior was).
|
68
|
-
|
69
|
-
== 1.14 / 2009-06-19
|
70
|
-
* Make :multi arguments default to [], not nil, when not set on the commandline.
|
71
|
-
* Minor commenting and error message improvements
|
72
|
-
|
73
|
-
== 1.13 / 2009-03-16
|
74
|
-
* Fix parsing of "--longarg=<value with spaces>".
|
75
|
-
|
76
|
-
== 1.12 / 2009-01-30
|
77
|
-
* Fix some unit test failures in the last release. Should be more careful.
|
78
|
-
* Make default short options only be assigned *after* all user-specified
|
79
|
-
short options. Now there's a little less juggling to do when you just
|
80
|
-
want to specify a few short options.
|
81
|
-
|
82
|
-
== 1.11 / 2009-01-29
|
83
|
-
* Set <opt>_given keys in the results hash for options that were specified
|
84
|
-
on the commandline.
|
85
|
-
|
86
|
-
== 1.10.2 / 2008-10-23
|
87
|
-
* No longer try `stty size` for screen size detection. Just use curses, and
|
88
|
-
screen users will have to deal with the screen clearing.
|
89
|
-
|
90
|
-
== 1.10.1 / 2008-10-22
|
91
|
-
* Options hash now responds to method calls as well as standard hash lookup.
|
92
|
-
* Default values for multi-occurrence parameters now autoboxed.
|
93
|
-
* The relationship between multi-value, multi-occurrence, and default values
|
94
|
-
improved and explained.
|
95
|
-
* Documentation improvements.
|
96
|
-
|
97
|
-
== 1.10 / 2008-10-21
|
98
|
-
* Added :io type for parameters that point to IO streams (filenames, URIs, etc).
|
99
|
-
* For screen size detection, first try `stty size` before loading Curses.
|
100
|
-
* Improved documentation.
|
101
|
-
|
102
|
-
== 1.9 / 2008-08-20
|
103
|
-
* Added 'stop_on_unknown' command to stop parsing on any unknown argument.
|
104
|
-
This is useful for handling sub-commands when you don't know the entire
|
105
|
-
set of commands up front. (E.g. if the initial arguments can change it.)
|
106
|
-
* Added a :multi option for parameters, signifying that they can be specified
|
107
|
-
multiple times.
|
108
|
-
* Added :ints, :strings, :doubles, and :floats option types, which can take
|
109
|
-
multiple arguments.
|
110
|
-
|
111
|
-
== 1.8.2 / 2008-06-25
|
112
|
-
* Bugfix for #conflicts and #depends error messages
|
113
|
-
|
114
|
-
== 1.8.1 / 2008-06-24
|
115
|
-
* Bugfix for short option autocreation
|
116
|
-
* More aggressive documentation
|
117
|
-
|
118
|
-
== 1.8 / 2008-06-16
|
119
|
-
* Sub-command support via Parser#stop_on
|
120
|
-
|
121
|
-
== 1.7.2 / 2008-01-16
|
122
|
-
* Ruby 1.9-ify. Apparently this means replacing :'s with ;'s.
|
123
|
-
|
124
|
-
== 1.7.1 / 2008-01-07
|
125
|
-
* Documentation improvements
|
126
|
-
|
127
|
-
== 1.7 / 2007-06-17
|
128
|
-
* Fix incorrect error message for multiple missing required arguments
|
129
|
-
(thanks to Neill Zero)
|
130
|
-
|
131
|
-
== 1.6 / 2007-04-01
|
132
|
-
* Don't attempt curses screen-width magic unless running on a terminal.
|
133
|
-
|
134
|
-
== 1.5 / 2007-03-31
|
135
|
-
* --help and --version do the right thing even if the rest of the
|
136
|
-
command line is incorrect.
|
137
|
-
* Added #conflicts and #depends to model dependencies and exclusivity
|
138
|
-
between arguments.
|
139
|
-
* Minor bugfixes.
|
140
|
-
|
141
|
-
== 1.4 / 2007-03-26
|
142
|
-
* Disable short options with :short => :none.
|
143
|
-
* Minor bugfixes and error message improvements.
|
144
|
-
|
145
|
-
== 1.3 / 2007-01-31
|
146
|
-
* Wrap at (screen width - 1) instead of screen width.
|
147
|
-
* User can override --help and --version.
|
148
|
-
* Bugfix in handling of -v and -h.
|
149
|
-
* More tests to confirm the above.
|
150
|
-
|
151
|
-
== 1.2 / 2007-01-31
|
152
|
-
* Minor documentation tweaks.
|
153
|
-
* Removed hoe dependency.
|
154
|
-
|
155
|
-
== 1.1 / 2007-01-30
|
156
|
-
* Optimist::options now passes any arguments as block arguments. Since
|
157
|
-
instance variables are not properly captured by the block, this
|
158
|
-
makes it slightly less noisy to pass them in as local variables.
|
159
|
-
(A real-life use for _why's cloaker!)
|
160
|
-
* Help display now preserves original argument order.
|
161
|
-
* Optimist::die now also has a single string form in case death is not
|
162
|
-
due to a single argument.
|
163
|
-
* Parser#text now an alias for Parser#banner, and can be called
|
164
|
-
multiple times, with the output being placed in the right position
|
165
|
-
in the help text.
|
166
|
-
* Slightly more indicative formatting for parameterized arguments.
|
167
|
-
|
168
|
-
== 1.0 / 2007-01-29
|
169
|
-
* Initial release.
|
170
|
-
|
171
|
-
[3.0.1]: https://github.com/ManageIQ/optimist/compare/v3.0.0...v3.0.1
|
172
|
-
[3.0.0]: https://github.com/ManageIQ/optimist/compare/v2.1.3...v3.0.0
|
173
|
-
[2.1.3]: https://github.com/ManageIQ/optimist/compare/v2.1.2...v2.1.3
|
174
|
-
[2.1.2]: https://github.com/ManageIQ/optimist/compare/v2.1.1...v2.1.2
|
175
|
-
[2.1.1]: https://github.com/ManageIQ/optimist/compare/v2.1.0...v2.1.1
|