Improve documentation for OptionParser
The documentation for OptionParser should be improved.
The current examples and and documentation do not yet describe
how to access non option args
I suggest to change the simple example in the doc as follows:
opts.banner = "Usage: example.rb [options] file ..."
p "files:" + ARGV
It should be stated explicitely in the description,
that parse! modifies the ARGV and removes all parseable args.
At least that is how I believe that the OptionParser.parse! works?
not yet tried it myself
#5 [ruby-core:51075] Updated by Marcus Stollsteimer over 3 years ago
- File rdoc_lib_optparse.patch added
I tried to make this clearer, see patch.
I also changed the example to avoid a warning for "shadowed outer local variable".
@zzak: Do you think that the "Further documentation" section is of any use in the current form (since changeset r36960)? I would suggest to remove it completely, since filing a ticket for usage questions seems not the right thing to do.
#6 Updated by Zachary Scott over 3 years ago
- Status changed from Assigned to Closed
- % Done changed from 0 to 100
This issue was solved with changeset r38561.
Eike, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
- lib/optparse.rb: Documentation for OptionParser to remove 'shadowed outer local variable' from example and make obvious ARGV with non-option arguments. Patch by Marcus Stollsteimer [Bug #6997]
#7 [ruby-core:51077] Updated by Zachary Scott over 3 years ago
Thanks Marcus, I was holding off on this until I got around to some other patches I have in mind for OptionParser, but you beat me to it :)
Re: remove further documentation: I think we should keep it, it doesn't hurt to mention the tracker if anyone comes across any bugs it will probably be documentation related when reading the optparse docs.