Sha256: 3e3cc996b4afc81f68e3bb4cf40dcc86de6b4473712d7fb04ddbc7d8bd5907dc
Contents?: true
Size: 1.33 KB
Versions: 1
Compression:
Stored size: 1.33 KB
Contents
require 'optiflag' # Example 2.3: # Variation 3: Adding alternate forms and long forms module Example extend OptiFlag::Flagset flag "dir" do alternate_forms "directory","D","d" description "The Appliction Directory" end optional_flag "log" do description "The directory in which to find the log files" long_form "logging-directory" # long form is keyed after the '--' symbol end flag "username", :description => "Database username." # alternate form flag "password" do description "Database password." end usage_flag "h","help","?" extended_help_flag "superhelp" handle_errors_and_help end # Some code to _use_ the values puts "User has input: #{ ARGV.flag_value.dir } for dir" puts "User has input: #{ ARGV.flag_value.username } for username" puts "User has input: #{ ARGV.flag_value.password } for password" if ARGV.flag_value.log? puts "User has input: #{ARGV.flag_value.log } for log" end # Try the following inputs #h# ruby example_2_3.rb -dir directory -username me -password fluffy # ruby example_2_3.rb -D directory -username me -password fluffy #h# ruby example_2_3.rb -d directory -username me -password fluffy ## Works (uses different long form for log): #h# ruby example_2_3.rb -d directory -username me -password fluffy --logging-directory c:/tmp/log
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
optiflag-0.6 | doc/example/example_2_3.rb |