* [ruby-core:63614] [ruby-trunk - Bug #10021] [Open] OptParse does not handle missing arguments bracketed by valid option switches
[not found] <redmine.issue-10021.20140709202103@ruby-lang.org>
@ 2014-07-09 20:21 ` byrnejb
2014-07-09 20:38 ` [ruby-core:63615] [ruby-trunk - Bug #10021] " byrnejb
2019-07-11 2:00 ` [ruby-core:93656] [Ruby master Bug#10021] " merch-redmine
2 siblings, 0 replies; 3+ messages in thread
From: byrnejb @ 2014-07-09 20:21 UTC (permalink / raw
To: ruby-core
Issue #10021 has been reported by James Byrne.
----------------------------------------
Bug #10021: OptParse does not handle missing arguments bracketed by valid option switches
https://bugs.ruby-lang.org/issues/10021
* Author: James Byrne
* Status: Open
* Priority: Normal
* Assignee:
* Category: core
* Target version:
* ruby -v: Ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux-gnu]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
OS=CentOS-6.5 x86_64
Ruby=2.1.2p95
I have this in an optparse structure:
# Create parser
opts = OptionParser.new do |opts|
opts.banner = <<-BANNER
. . .
opts.on("-r", "--rerun=DATEorTRANSACTION", "--re-run=DATEorTRANSACTION",
"Re-run extract for specific date (yyyymmdd)",
" or transaction number (SSSSSNNNNNNNNC).",
" Multiple specifications are ORed for selections.",
" All billable transactions are selectable",
" whether previously billed or not.",
" Sets and enforces --no-update" ) do |rr|
options.rerun << rr
options.update = false
end
. . .
If I run a program incorporating this option class so:
--re-run x --rerun y -r
Then I see this:
missing argument: -r
However, if I do this:
--re-run x --rerun y -r --debug
or this
--re-run x -r --rerun y
Then the program runs and does not report the missing argument.
Is this the intended behaviour? It does not seem correct to me.
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 3+ messages in thread
* [ruby-core:63615] [ruby-trunk - Bug #10021] OptParse does not handle missing arguments bracketed by valid option switches
[not found] <redmine.issue-10021.20140709202103@ruby-lang.org>
2014-07-09 20:21 ` [ruby-core:63614] [ruby-trunk - Bug #10021] [Open] OptParse does not handle missing arguments bracketed by valid option switches byrnejb
@ 2014-07-09 20:38 ` byrnejb
2019-07-11 2:00 ` [ruby-core:93656] [Ruby master Bug#10021] " merch-redmine
2 siblings, 0 replies; 3+ messages in thread
From: byrnejb @ 2014-07-09 20:38 UTC (permalink / raw
To: ruby-core
Issue #10021 has been updated by James Byrne.
When I try this:
`--re-run x -r --rerun y -- file`
Then I see this
`:in `eval': Only one output filename is permitted (RuntimeError)
`
From which I infer that -r has 'eaten' --rerun as its argument and is treating y as the file name (args[0])
But if I do this:
`--re-run x -re-run --rerun y -- file
`
Then the program runs. I exposed the structures with a debug routine and this is what they show:
`Options before parsing with --debug
Number of arguments passed: 8
Arguments passed are:
---
- "--debug"
- "--re-run"
- x
- "-re-run"
- "--rerun"
- y
- "--"
- file
Argument object contains:
["--debug", "--re-run", "x", "-re-run", "--rerun", "y", "--", "file"]`
----------------------------------------
Bug #10021: OptParse does not handle missing arguments bracketed by valid option switches
https://bugs.ruby-lang.org/issues/10021#change-47669
* Author: James Byrne
* Status: Open
* Priority: Normal
* Assignee:
* Category: core
* Target version:
* ruby -v: Ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux-gnu]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
OS=CentOS-6.5 x86_64
Ruby=2.1.2p95
I have this in an optparse structure:
# Create parser
opts = OptionParser.new do |opts|
opts.banner = <<-BANNER
. . .
opts.on("-r", "--rerun=DATEorTRANSACTION", "--re-run=DATEorTRANSACTION",
"Re-run extract for specific date (yyyymmdd)",
" or transaction number (SSSSSNNNNNNNNC).",
" Multiple specifications are ORed for selections.",
" All billable transactions are selectable",
" whether previously billed or not.",
" Sets and enforces --no-update" ) do |rr|
options.rerun << rr
options.update = false
end
. . .
If I run a program incorporating this option class so:
--re-run x --rerun y -r
Then I see this:
missing argument: -r
However, if I do this:
--re-run x --rerun y -r --debug
or this
--re-run x -r --rerun y
Then the program runs and does not report the missing argument.
Is this the intended behaviour? It does not seem correct to me.
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 3+ messages in thread
* [ruby-core:93656] [Ruby master Bug#10021] OptParse does not handle missing arguments bracketed by valid option switches
[not found] <redmine.issue-10021.20140709202103@ruby-lang.org>
2014-07-09 20:21 ` [ruby-core:63614] [ruby-trunk - Bug #10021] [Open] OptParse does not handle missing arguments bracketed by valid option switches byrnejb
2014-07-09 20:38 ` [ruby-core:63615] [ruby-trunk - Bug #10021] " byrnejb
@ 2019-07-11 2:00 ` merch-redmine
2 siblings, 0 replies; 3+ messages in thread
From: merch-redmine @ 2019-07-11 2:00 UTC (permalink / raw
To: ruby-core
Issue #10021 has been updated by jeremyevans0 (Jeremy Evans).
Status changed from Open to Closed
I believe this is the intended behavior. You are using a required argument for the `-r` option, so for `--re-run x --rerun y -r --debug` the `-r` option arguments are `['x', 'y', '--debug']`, with no regular arguments. For `--re-run x -r --rerun y`, the `-r` option arguments are `['x', '--rerun']`, with remaining arguments `['y']`. For `--re-run x -r --rerun y -- file`, the `-r` option arguments are `['x', '--rerun']`, with remaining arguments `['y', 'file']`
It sounds like you want to use an optional argument:
```ruby
opts.on("-r", "--rerun [DATEorTRANSACTION]", "--re-run [DATEorTRANSACTION]"){|rr|}
```
With an optional argument, for `--re-run x --rerun y -r --debug` the '-r' option arguments are `['x', 'y', nil]`, with a `--debug` option and no regular arguments. For `--re-run x -r --rerun y`, the `-r` option arguments are `['x', nil, 'y']`, with no remaining arguments. For `--re-run x -r --rerun y -- file`, the `-r` option arguments are `['x', nil, 'y']`, with remaining arguments `['file']`
----------------------------------------
Bug #10021: OptParse does not handle missing arguments bracketed by valid option switches
https://bugs.ruby-lang.org/issues/10021#change-79266
* Author: byrnejb (James Byrne)
* Status: Closed
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: Ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux-gnu]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
OS=CentOS-6.5 x86_64
Ruby=2.1.2p95
I have this in an optparse structure:
# Create parser
opts = OptionParser.new do |opts|
opts.banner = <<-BANNER
. . .
opts.on("-r", "--rerun=DATEorTRANSACTION", "--re-run=DATEorTRANSACTION",
"Re-run extract for specific date (yyyymmdd)",
" or transaction number (SSSSSNNNNNNNNC).",
" Multiple specifications are ORed for selections.",
" All billable transactions are selectable",
" whether previously billed or not.",
" Sets and enforces --no-update" ) do |rr|
options.rerun << rr
options.update = false
end
. . .
If I run a program incorporating this option class so:
--re-run x --rerun y -r
Then I see this:
missing argument: -r
However, if I do this:
--re-run x --rerun y -r --debug
or this
--re-run x -r --rerun y
Then the program runs and does not report the missing argument.
Is this the intended behaviour? It does not seem correct to me.
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-07-11 2:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <redmine.issue-10021.20140709202103@ruby-lang.org>
2014-07-09 20:21 ` [ruby-core:63614] [ruby-trunk - Bug #10021] [Open] OptParse does not handle missing arguments bracketed by valid option switches byrnejb
2014-07-09 20:38 ` [ruby-core:63615] [ruby-trunk - Bug #10021] " byrnejb
2019-07-11 2:00 ` [ruby-core:93656] [Ruby master Bug#10021] " merch-redmine
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).