The help flag? ...You get it for free.
So you have the code below and you see nothing about a
help flag. But, in fact, it's there. Go ahead. Try typing in
something that doesn't work. Or use the -h or -? flag.
What the user types in, and the results (notice that we are purposely leaving out the required flag 'log'):
require 'optiflag' module DBChecker extend OptiFlagSet flag "log" flag "password" flag "user" and_process! end puts "The user's user name is #{ ARGV.flags.user }" puts "The user's password is #{ ARGV.flags.password }" puts "The log directory is #{ ARGV.flags.log }"
What the user types in, and the results (notice that we are purposely leaving out the required flag 'log'):
>
ruby dbchecker.rb -user wluser -password ch3ckM8
Errors found:
Missing Flags:
-log
Help for commands:
-user (Required, takes 1 argument)
-password (Required, takes 1 argument)
-log (Required, takes 1 argument)
-h (Optional, takes 0 arguments)
HelpOr, with the -h or -? flag:
>
ruby dbchecker.rb -?
Help for commands:
-user (Required, takes 1 argument)
-password (Required, takes 1 argument)
-log (Required, takes 1 argument)
-h (Optional, takes 0 arguments)
HelpOr, you can target the -? flag to a specific option, (for instance, 'user'):
>
ruby dbchecker.rb -? user
----------------
Flag: -user (Required, takes 1 argument)
Long Form: --user

