Граф коммитов

67 Коммитов

Автор SHA1 Сообщение Дата
fatkodima a35d324862 [ruby/optparse] Fix parsing array arguments with `:into` option
https://github.com/ruby/optparse/commit/19700e96d8
2024-08-05 02:28:12 +00:00
Nobuyoshi Nakada 5d76fe6b2a [ruby/optparse] Invoke pager for `--help`
https://github.com/ruby/optparse/commit/77dccce37c
2024-03-01 07:10:08 +00:00
Nobuyoshi Nakada 41c0fb6991 [ruby/optparse] Add `exact:` keyword argument
https://github.com/ruby/optparse/commit/07e83673a8
2024-02-23 21:16:59 +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

https://github.com/ruby/optparse/commit/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

https://github.com/ruby/optparse/commit/9d53e74aa4
2024-02-09 19:58:19 +09:00
fatkodima f7a407cabd [ruby/optparse] Fix `require_exact` to work with options defined as `--[no]-something`
https://github.com/ruby/optparse/commit/4e346ad337
2024-02-09 03:31:13 +00:00
Junichi Ito cea6951ecf [ruby/optparse] Add symbolize_names to getopts
https://github.com/ruby/optparse/commit/3e63d878f8
2022-12-26 15:09:21 +09:00
Nobuyoshi Nakada 502ca37dde [ruby/optparse] The encoding argument of `Regexp.new` has been ignored since 1.9
https://github.com/ruby/optparse/commit/766f567405
2022-12-21 14:09:12 +09:00
Yusuke Endoh f3ad68dd16 [ruby/optparse] Fix the test failure i ruby/ruby
```
$ make test-all TESTS=test/optparse/
...

[148/178] TestOptionParserDidYouMean#test_raise_unknown = 0.00 s
  1) Failure:
TestOptionParserDidYouMean#test_raise_unknown [/home/mame/work/ruby/test/optparse/test_optparse.rb:106]:
<["--bar"]> expected but was
<[]>.
```

In the old test/unit (bundled in ruby/ruby), when a test class inherits from
another test class, the child class runs all the tests defined in the parent
class.
However, it looks like the new test/unit does not do so. This is because the
test failure does not occur in ruby/optparse.

As a tentative solution, this changes the option names in TestOptionParser to
avoid the name conflict with TestOptionParserDidYouMean.

https://github.com/ruby/optparse/commit/fee86ef7a4
2022-11-28 16:20:40 +00:00
Nobuyoshi Nakada 0bfb185654 [ruby/optparse] Add `raise_unknown` flag
(https://github.com/ruby/optparse/pull/38)

https://github.com/ruby/optparse/commit/12529653cd
2022-11-28 14:24:06 +00:00
Nobuyoshi Nakada d5fb76a6c8 [ruby/optparse] Add tests for `load(into:)`
https://github.com/ruby/optparse/commit/51f7e060ee
2022-10-29 13:47:23 +00:00
Nobuyoshi Nakada 4dac53f0a4 [ruby/optparse] Add tests for `OptionParser#load`
https://github.com/ruby/optparse/commit/fb34a1d3a3
2022-10-29 13:40:19 +00:00
Maciek Rząsa 0f231f2bab [ruby/optparse] Don't treat empty string as an option description
https://github.com/ruby/optparse/commit/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)
https://github.com/ruby/optparse/commit/f2b8318631
2022-07-29 19:10:10 +09:00
Jeremy Evans ab3cb29bd9 Avoid defining the same test class in multiple files
Should fix issues with parallel testing sometimes not running all
tests.

This should be viewed skipping whitespace changes.

Fixes [Bug #18731]
2022-04-22 15:00:16 -07:00
Nobuyoshi Nakada e28dbd0f3d
[ruby/optparse] Fix for ruby 3.0 or earlier
https://github.com/ruby/optparse/commit/9e29d86c12
2022-01-12 21:16:02 +09:00
Nobuyoshi Nakada 743a41f7e3
[ruby/optparse] DidYouMean::PlainFormatter is deprecated
https://github.com/ruby/optparse/commit/0ac9957696
2022-01-12 21:16:02 +09:00
Yuki Nishijima 03c54a09ec Revert "Revert "Replace an deprecated constant with a new one in did_you_mean""
This reverts commit 1527f7569b.
2021-12-24 23:21:55 +09:00
Yuki Nishijima 1527f7569b Revert "Replace an deprecated constant with a new one in did_you_mean"
This reverts commit 573d9d3a4a.
2021-12-23 10:48:27 +09:00
Yuki Nishijima 573d9d3a4a Replace an deprecated constant with a new one in did_you_mean 2021-12-22 21:21:27 +09:00
Nobuyoshi Nakada b5d9c44267 [ruby/optparse] Fix typo [ci skip]
https://github.com/ruby/optparse/commit/0aa18752cf
2021-11-03 19:55:24 +09:00
Yuki Nishijima 905be49bf6 Remove the test for DYM's verbose formatter 2021-10-22 21:14:01 -04:00
Alexander Popov 2afbe7113a
[ruby/optparse] Add EditorConfig file
More info here: https://editorconfig.org/

For example, `ruby/ruby` has it: https://github.com/ruby/ruby/blob/05ebaee/.editorconfig

Also fix some offenses.

https://github.com/ruby/optparse/commit/29402e7e0e
2021-04-28 11:56:15 +09:00
Nobuyoshi Nakada e8317d90b0
[ruby/optparse] Fixed error message of unparsed non-option
Close https://github.com/ruby/optparse/issues/3

https://github.com/ruby/optparse/commit/94c5cf4032
2021-03-29 19:37:24 +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

https://github.com/ruby/optparse/commit/dfefb2d2e2
2021-03-29 15:55:41 +09:00
Nobuyoshi Nakada 5ad32d5504
`LoadError` is not a subclass of `StandardError` 2019-11-29 11:25:23 +09:00
MSP-Greg 71ffe40a44 test/optparse/test_did_you_mean.rb - fix suggestion order 2019-10-21 09:53:56 +09:00
Nobuyoshi Nakada e2b719bed6
Support DidYouMean by AmbiguousOption too 2019-10-18 17:46:53 +09:00
Nobuyoshi Nakada e29e49abf0
Default DidYouMean.formatter to PlainFormatter 2019-10-18 16:43:40 +09:00
Nobuyoshi Nakada d4e52f672c
Added no suggestion test case 2019-10-18 15:19:26 +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
Nobuyoshi Nakada ef45fd53e4
Fixed the test-case class name for zsh 2019-06-28 14:09:17 +09:00
Nobuyoshi Nakada c9b28fd7ae
Allow --enable/--disable options to take an argument
[Bug #15850]
2019-05-15 17:31:11 +09:00
nobu 2ad7fb6dc1 optparse: Suppress warnings
Ruby warns "instance variable `@version` not initialized" for optparse when it receives `--version` option.

`test.rb`

```ruby
require 'optparse'
Version = '1'
OptionParser.new.parse(ARGV)
```

```
$ ruby -w test.rb --version
/home/pocke/.rbenv/versions/2.5.1/lib/ruby/2.5.0/optparse.rb:1168: warning: instance variable @version not initialized
/home/pocke/.rbenv/versions/2.5.1/lib/ruby/2.5.0/optparse.rb:1175: warning: instance variable @release not initialized
test 1
```

This change will suppress the warnings.

[Fix GH-1871]

From: Masataka Pocke Kuwabara <kuwabara@pocke.me>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63342 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-05-06 09:53:33 +00:00
nobu db1de35a31 optparse.rb: froze string literals
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62047 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-26 03:41:04 +00:00
nobu 30d23ec903 multiple arguments to write
Make write methods of IO-like objects accept multiple arguments,
as well as IO#write.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60383 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-23 14:05:07 +00:00
nobu 3fe5d355a8 optparse.rb: case-sensitive candidate
* lib/optparse.rb (candidate): short options are case-sensitive by
  the default, should not match case-different options..
  https://github.com/mernen/completion-ruby/pull/9#issuecomment-317287946

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59412 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-24 01:56:04 +00:00
nobu 89bf90a370 optparse.rb: get rid of eval
* lib/optparse.rb: try Float() and Integer() instead of eval,
  which does too much things.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59312 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-12 02:49:53 +00:00
nobu 8ddf0263bb Fix DecimalInteger converting to octal bug
Previously if the input started with a '0' then it will be converted
as octal even though it has been specified as a decimal. This commit
forces the number to be interpreted as a decimal.

[ruby-core:81927] [Bug #13722] [Fix GH-1665]
Author:    william <william.mccumstie@outlook.com>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59273 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-06 11:49:03 +00:00
nobu 0687baaf57 optparse/kwargs.rb
* lib/optparse/kwargs.rb (OptionParser#define_by_keywords):
  [EXPERIMENTAL] extract command line option definitions from the
  information of keyword arguments.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56423 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-14 13:26:13 +00:00
nobu 99ad512486 optparse.rb: hyphenize
* lib/optparse.rb (make_switch, parse_in_order): unify underscores
  to hyphens.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56419 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-14 08:20:26 +00:00
nobu dd1be236d9 optparse.rb: fix char class option
* lib/optparse.rb (OptionParser::Completion.candidate): get rid of
  nil as key names.  [ruby-core:75773] [Bug #12438]
* lib/optparse.rb (OptionParser#make_switch): char class option
  cannot be NoArgument, default to RequiredArgument.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55228 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-31 08:28:48 +00:00
nobu 49684589cd optparse.rb: into kwdarg
* lib/optparse.rb (OptionParser#order!): add `into` optional
  keyword argument to store the results.  [Feature #11191]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53444 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-01-06 08:23:10 +00:00
naruse 3e92b635fb Add frozen_string_literal: false for all files
When you change this to true, you may need to add more tests.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-16 05:07:31 +00:00
nobu ae042f21fb use assert_raise
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50727 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-02 02:18:44 +00:00
drbrain ee155140e8 * lib/optparse.rb: The Integer acceptable now allows binary and
hexadecimal numbers per the documentation.  [ruby-trunk - Bug #8865]

  DecimalInteger, OctalInteger, DecimalNumeric now validate their input
  before converting to a number.  [ruby-trunk - Bug #8865]

* test/optparse/test_acceptable.rb:  Tests for the above, tests for all
  numeric acceptables for existing behavior.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42844 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-05 05:02:17 +00:00
nobu b5550361c9 test_optparse.rb: skip no_error in backtrace
* test/optparse/test_optparse.rb (TestOptionParser#assert_no_error):
  prefix with assert_ so it will be skipped in backtrace.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40041 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-01 15:00:36 +00:00
nagachika 2bc4268e79 * test/optparse/test_summary.rb (test_summary_containing_space): add
test for r35467. OptionParser#to_a shouldn't split banner by spaces.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35473 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-25 16:36:14 +00:00
nobu 3c2f707f16 * lib/optparse.rb (OptionParser#to_a): split for each lines.
[ruby-dev:45568][Bug #6348]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35467 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-24 20:46:14 +00:00