Sha256: 7a667447595b21701f7c62d49e1cb124260b59a8b7aade77e5cf5c3faacfbe5b
Contents?: true
Size: 1.3 KB
Versions: 1
Compression:
Stored size: 1.3 KB
Contents
require 'optiflag' # Example 2_4: # Variation 4: Selectively changing the symbol for a flag, and change the arity to be no-args 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" end flag "username", :description => "Database username." flag "password" do description "Database password." end optional_flag "delete" do no_args # stating that this flag accepts no arguments description "Delete database when done. Use carefully!!" dash_symbol "!" # changing the symbol here long_dash_symbol "!!" # changing its long form here end usage_flag "h","help","?" extended_help_flag "superhelp" handle_errors_and_help end if ARGV.flag_value.delete? # super dangerous code to delete the database.... puts "Special DELETE flag invoked with special flag-symbol" end ## Works (uses delete flag with different switch symbol): #h# ruby example_2_4.rb -d directory -username me -password fluffy !!delete --logging-directory c:/tmp/log # ruby example_2_4.rb -d directory -username me -password fluffy !delete --logging-directory c:/tmp/log
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
optiflag-0.6 | doc/example/example_2_4.rb |