diff options
| author | Burdette Lamar <BurdetteLamar@Yahoo.com> | 2021-04-10 16:30:19 -0500 |
|---|---|---|
| committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2021-04-11 08:52:54 +0900 |
| commit | 1bad4bdf524fc07be8ece1dc784fdbedc07d8a97 (patch) | |
| tree | 80948d35713f8ab4a27ea0d7d57eb0ba7e0e03f9 /doc/ruby/default_values.rb | |
| parent | ff0dac184902e42fac148940cd6c026679a0ee21 (diff) | |
[ruby/optparse] More on tutorial (#16)
- Added example in "Argument Converters"; it doesn't seem right for a tutorial to have no example in one of its topics (and instead just linking elsewhere).
- Added section "Command-Line Abbreviations."
- Added section "Keyword Argument into," showing how to:
- Collect options.
- Check for missing options.
- Provide option defaults.
https://github.com/ruby/optparse/commit/39d39676c4
Diffstat (limited to 'doc/ruby/default_values.rb')
| -rw-r--r-- | doc/ruby/default_values.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/doc/ruby/default_values.rb b/doc/ruby/default_values.rb new file mode 100644 index 0000000000..24c26faea2 --- /dev/null +++ b/doc/ruby/default_values.rb @@ -0,0 +1,8 @@ +require 'optparse' +parser = OptionParser.new +parser.on('-x', '--xxx', 'Short and long, no argument') +parser.on('-yYYY', '--yyy', 'Short and long, required argument') +parser.on('-z [ZZZ]', '--zzz', 'Short and long, optional argument') +options = {yyy: 'AAA', zzz: 'BBB'} +parser.parse!(into: options) +p options |
