Commit graph

207 commits

Author SHA1 Message Date
Nobuyoshi Nakada
5fd3942466 [ruby/optparse] Prefer require_relative
bb08cd47a8
2024-09-03 04:43:25 +00:00
fatkodima
a35d324862 [ruby/optparse] Fix parsing array arguments with :into option
19700e96d8
2024-08-05 02:28:12 +00:00
Nobuyoshi Nakada
fc363944b4 [ruby/optparse] bump up to 0.5.0
f5018a8b1c
2024-04-15 05:06:46 +00:00
Koichi Sasada
9180e33ca3 show warning for unused block
With verbopse mode (-w), the interpreter shows a warning if
a block is passed to a method which does not use the given block.

Warning on:

* the invoked method is written in C
* the invoked method is not `initialize`
* not invoked with `super`
* the first time on the call-site with the invoked method
  (`obj.foo{}` will be warned once if `foo` is same method)

[Feature #15554]

`Primitive.attr! :use_block` is introduced to declare that primitive
functions (written in C) will use passed block.

For minitest, test needs some tweak, so use
ea9caafc07
for `test-bundled-gems`.
2024-04-15 12:08:07 +09:00
Nobuyoshi Nakada
5d76fe6b2a [ruby/optparse] Invoke pager for --help
77dccce37c
2024-03-01 07:10:08 +00:00
Nobuyoshi Nakada
7da3f8dcd3 [ruby/optparse] [DOC] About return value of OptionParser#new
59b9fd7ddc
2024-02-23 12:50:08 +00:00
Nobuyoshi Nakada
41c0fb6991 [ruby/optparse] Add exact: keyword argument
07e83673a8
2024-02-23 21:16:59 +09:00
Yusuke Endoh
25d74b9527 Do not include a backtick in error messages and backtraces
[Feature #16495]
2024-02-15 18:42:31 +09:00
Nobuyoshi Nakada
bbccabe6d6 [ruby/optparse] [DOC] Add missing documents
33956ce93f
2024-02-11 16:08:14 +00:00
Nobuyoshi Nakada
f960fbc102 [ruby/optparse] Search exactly when require_exact
To work with options defined as `--[no]-something`.

Fix https://bugs.ruby-lang.org/issues/20252
Fix https://github.com/ruby/optparse/pull/60

78afdab307
2024-02-11 00:47:41 +09:00
Nobuyoshi Nakada
db73226bf6 [ruby/optparse] Adjust arguments for lambda-callbacks
Rake uses [lambda] as callbacks.
Calling it without omitted argument raises an `ArgumentError`.

lambda: https://github.com/ruby/rake/blob/master/lib/rake/application.rb#L543

213cb03b59
2024-02-09 19:58:31 +09:00
Nobuyoshi Nakada
2c6767b71e [ruby/optparse] Respect default values in block parameters
Fix https://github.com/ruby/optparse/pull/55

9d53e74aa4
2024-02-09 19:58:19 +09:00
fatkodima
f7a407cabd [ruby/optparse] Fix require_exact to work with options defined as --[no]-something
4e346ad337
2024-02-09 03:31:13 +00:00
Nobuyoshi Nakada
50bcaa6286 [ruby/optparse] Escape backslashes
b14c2c644d
2024-02-09 03:21:24 +00:00
Nobuyoshi Nakada
e55a57af1e [ruby/optparse] [DOC] Add missing documents
324ff21f04
2023-12-25 21:12:49 +09:00
Hiroshi SHIBATA
3f33bfa1e5 [ruby/optparse] Bump up 0.4.0
acbf6e3e12
2023-11-07 01:40:53 +00:00
Nobuyoshi Nakada
dfad14d83f [ruby/optparse] [DOC] Mark up constant and method names as code
e8bee0be8f
2023-07-30 02:35:22 +00:00
Jeremy Evans
bb927acd3b [ruby/optparse] Document requires needed for Date/DateTime/Time/URI/Shellwords support
Fixes [Bug #19566]

fb91d97c10
2023-04-04 23:43:58 +00:00
Junichi Ito
cea6951ecf [ruby/optparse] Add symbolize_names to getopts
3e63d878f8
2022-12-26 15:09:21 +09:00
Nobuyoshi Nakada
4c767c1354 [ruby/optparse] bump up to 0.4.0.pre.1
73661899ad
2022-12-26 15:09:21 +09:00
Hiroshi SHIBATA
fe7190a8c1
[ruby/optparse] Bump version to 0.3.1
2a1e157ae1
2022-12-22 17:48:22 +09:00
Nobuyoshi Nakada
502ca37dde [ruby/optparse] The encoding argument of Regexp.new has been ignored since 1.9
766f567405
2022-12-21 14:09:12 +09:00
Hiroshi SHIBATA
71b4d35526 [ruby/optparse] Bump version to 0.3.0
c80dfb1ebd
2022-12-05 07:17:23 +00:00
Nobuyoshi Nakada
0bfb185654 [ruby/optparse] Add raise_unknown flag
(https://github.com/ruby/optparse/pull/38)

12529653cd
2022-11-28 14:24:06 +00:00
Nobuyoshi Nakada
e2b15461a7 [ruby/optparse] Use class methods of File over IO
ab5073e4d8
2022-11-21 10:26:42 +00:00
Whyme Lyu
37291df91d [ruby/optparse] #load() into hash
(https://github.com/ruby/optparse/pull/42)

OptionParser#load learns .load(into: Hash)

2ea626fcff

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2022-10-29 13:46:27 +00:00
Maciek Rząsa
0f231f2bab [ruby/optparse] Don't treat empty string as an option description
078638ee6d
2022-10-08 19:30:34 +09:00
konsolebox
419ad1e13e [ruby/optparse] Also accept '-' as an optional argument (https://github.com/ruby/optparse/pull/35)
f2b8318631
2022-07-29 19:10:10 +09:00
Nobuyoshi Nakada
de427c3ce0 [ruby/optparse] Define inspect and pretty_inspect
a3f0ec21b1
2022-04-04 15:05:44 +09:00
Nobuyoshi Nakada
92630e2346
[ruby/optparse] Fix links to the page directory files [Bug #18468]
dab72c543d
2022-01-12 21:16:02 +09:00
Hiroshi SHIBATA
b8d49d0d01 [ruby/optparse] Bump up optparse version to 0.2.0
1226b670e6
2021-10-21 21:01:34 +09:00
Burdette Lamar
27679b349e
[ruby/optparse] More on tutorial (https://github.com/ruby/optparse/pull/23)
- Removed a largish block of repeated text.
- Added sections "Top List and Base List" and "Methods for Defining Options" (on, define, etc.).
- Linked from class OptionParser doc to the tutorial.

7f3195b9db
2021-07-28 20:13:39 +09:00
Nobuyoshi Nakada
bf175e7ec2
[ruby/optparse] nodoc private methods
f23d750d14
2021-07-28 20:13:38 +09:00
Nobuyoshi Nakada
f89486965b [ruby/optparse] Moved rdoc files to doc/optparse
cccb28e0de
2021-04-11 09:03:36 +09:00
BurdetteLamar
a5ecce9187
[ruby/optparse] Make use of option_params.rdoc
d55d9284c3
2021-04-08 12:11:42 +09:00
Nobuyoshi Nakada
190a57b168
[ruby/optparse] bump up to 0.1.1
2fe984a603
2021-03-29 19:37:25 +09:00
Nobuyoshi Nakada
e8317d90b0
[ruby/optparse] Fixed error message of unparsed non-option
Close https://github.com/ruby/optparse/issues/3

94c5cf4032
2021-03-29 19:37:24 +09:00
BurdetteLamar
7846f3201a
[ruby/optparse] Change *opts to *params, to avoid confusion
f5f5e202dd
2021-03-29 15:55:41 +09:00
Jeremy Evans
eca8ffaa0b
[ruby/optparse] Add OptionParser#require_exact accessor
This allows you to disable allowing abbreviations of long options
and using short options for long options.

Implements Ruby Feature #11523

dfefb2d2e2
2021-03-29 15:55:41 +09:00
Nobuyoshi Nakada
3198e7abd7
Separate send into public_send and __send__ 2020-10-27 16:12:45 +09:00
Nobuyoshi Nakada
f120e65200 [ruby/optparse] Define OptionParser::Version
4c0021b5b2
2020-07-23 10:57:33 +09:00
Nobuyoshi Nakada
fb6a489af2
Revert "Method reference operator"
This reverts commit 67c5747369.
[Feature #16275]
2019-11-12 17:24:48 +09:00
zverok
f93cb6904c OptionParser: document into: argument 2019-10-26 10:24:20 -07:00
Nobuyoshi Nakada
263ee6639d
Make suggestions order stable [Bug #16263]
As the result order of `DidYouMean::SpellChecker#correct` is
undefined, keep the order of the original candidates.
2019-10-21 09:54:11 +09:00
Nobuyoshi Nakada
e2b719bed6
Support DidYouMean by AmbiguousOption too 2019-10-18 17:46:53 +09:00
Nobuyoshi Nakada
b4d308b419
Defer adding additional info until getting the message of an error 2019-10-18 17:39:16 +09:00
Nobuyoshi Nakada
46fa301e82
Use DidYouMean.formatter
Instead of building messages separately.
2019-10-18 15:18:36 +09:00
Yusuke Endoh
c3b64a86bc lib/optparse.rb: Show a did_you_mean hint for unknown option
```
require 'optparse'

OptionParser.new do |opts|
  opts.on("-f", "--foo", "foo") {|v| }
  opts.on("-b", "--bar", "bar") {|v| }
  opts.on("-c", "--baz", "baz") {|v| }
end.parse!
```

```
$ ruby test.rb --baa
Traceback (most recent call last):
test.rb:7:in `<main>': invalid option: --baa (OptionParser::InvalidOption)
Did you mean?  baz
               bar
```
2019-10-18 12:20:58 +09:00
Jeremy Evans
3fcffceafd Fix default argument values for OptParse::Switch#summarize
The documentation describes these arguments being hashes, and the method
is called with hashes, so a hash default makes more sense.

The method would fail previously if called without arguments and @short
or @long contained a non-integer value.

Fixes [Bug #10928]
2019-07-07 13:49:47 -07:00
Nobuyoshi Nakada
7e72ce0f73
Load OptionParser defaults from XDG and Haiku standards 2019-05-06 15:30:44 +09:00