Sha256: f52332104baa339e89c6b793b7ecff1a356312b24bd9c543a4654ee38d39290b

Contents?: true

Size: 1014 Bytes

Versions: 1

Compression:

Stored size: 1014 Bytes

Contents

require 'optiflag'

# Example 1.2:  
#   Variation 2: Changing the universal short-form default symbol from '-' to '/'
module Example extend OptiFlag::Flagset(:flag_symbol => "/")
  flag "dir"
  flag "log"
  flag "username"
  flag "password"

  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.log  } for log"
puts "User has input:#{ ARGV.flag_value.username  } for username"
puts "User has input:#{ ARGV.flag_value.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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
optiflag-0.6 doc/example/example_1_2.rb