summaryrefslogtreecommitdiff
path: root/doc/optparse/ruby/proc.rb
diff options
context:
space:
mode:
Diffstat (limited to 'doc/optparse/ruby/proc.rb')
-rw-r--r--doc/optparse/ruby/proc.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/doc/optparse/ruby/proc.rb b/doc/optparse/ruby/proc.rb
new file mode 100644
index 0000000000..9c669fdc92
--- /dev/null
+++ b/doc/optparse/ruby/proc.rb
@@ -0,0 +1,13 @@
+require 'optparse'
+parser = OptionParser.new
+parser.on(
+ '--xxx',
+ 'Option with no argument',
+ ->(value) {p ['Handler proc for -xxx called with value:', value]}
+)
+parser.on(
+ '--yyy YYY',
+ 'Option with required argument',
+ ->(value) {p ['Handler proc for -yyy called with value:', value]}
+)
+parser.parse!