summaryrefslogtreecommitdiff
path: root/sample/getoptlong/require_order.rb
diff options
context:
space:
mode:
authorHiroshi SHIBATA <[email protected]>2022-05-09 07:10:45 +0900
committergit <[email protected]>2022-05-09 07:13:55 +0900
commitf7539d5758ee5c83e6ec7792b100e830180896fd (patch)
tree748d9b2657b62b70e3f9865a493734275d272c33 /sample/getoptlong/require_order.rb
parent98e3fdb44458615a1376cc60ea0909d07a6c2e4a (diff)
[ruby/getoptlong] ruby/ruby used sample, not examples
https://github.com/ruby/getoptlong/commit/39faa7b390
Diffstat (limited to 'sample/getoptlong/require_order.rb')
-rw-r--r--sample/getoptlong/require_order.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/sample/getoptlong/require_order.rb b/sample/getoptlong/require_order.rb
new file mode 100644
index 0000000000..357f667905
--- /dev/null
+++ b/sample/getoptlong/require_order.rb
@@ -0,0 +1,13 @@
+require 'getoptlong'
+
+options = GetoptLong.new(
+ ['--xxx', GetoptLong::REQUIRED_ARGUMENT],
+ ['--yyy', GetoptLong::OPTIONAL_ARGUMENT],
+ ['--zzz', GetoptLong::NO_ARGUMENT]
+)
+options.ordering = GetoptLong::REQUIRE_ORDER
+puts "Original ARGV: #{ARGV}"
+options.each do |option, argument|
+ p [option, argument]
+end
+puts "Remaining ARGV: #{ARGV}"