From 1bad4bdf524fc07be8ece1dc784fdbedc07d8a97 Mon Sep 17 00:00:00 2001 From: Burdette Lamar Date: Sat, 10 Apr 2021 16:30:19 -0500 Subject: [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 --- doc/ruby/default_values.rb | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 doc/ruby/default_values.rb (limited to 'doc/ruby/default_values.rb') 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 -- cgit v1.2.3