Changing the universal short-form symbol
require 'optiflag' # Title: Changing the universal short-form symbol # Description: Everything is still the same, except we are now changing the default symbol from '-' to '/' module Example extend OptiFlagSet(:flag_symbol => "/") flag "dir" flag "log" flag "username" flag "password" and_process! end # Some code to _use_ the values puts "User has input:#{ ARGV.flags.dir } for dir" puts "User has input:#{ ARGV.flags.log } for log" puts "User has input:#{ ARGV.flags.username } for username" puts "User has input:#{ ARGV.flags.password } for password" # Try the following inputs ## Breaks: # ruby example_1_2.rb #h# ruby example_1_2.rb -log logdirectory -dir directory -username me -password fluffy ## Works: #h# ruby example_1_2.rb /log logdirectory /dir directory /username me /password fluffy # ruby example_1_2.rb --log logdirectory --dir directory --username me --password fluffy #h# ruby example_1_2.rb --log logdirectory /dir directory --username me /password fluffy
Changing the universal short-form symbol
>ruby example_1_2.rb -log logdirectory -dir directory -username me -password fluffy
Errors found: Missing Flags: /dir /log /username /password
>ruby example_1_2.rb /log logdirectory /dir directory /username me /password fluffy
User has input:directory for dir User has input:logdirectory for log User has input:me for username User has input:fluffy for password
>ruby example_1_2.rb --log logdirectory /dir directory --username me /password fluffy
User has input:directory for dir User has input:logdirectory for log User has input:me for username User has input:fluffy for password


Back to Examples