diff options
author | Lee Jarvis <ljjarvis@gmail.com> | 2014-10-08 09:14:49 +0100 |
---|---|---|
committer | Lee Jarvis <ljjarvis@gmail.com> | 2014-10-08 09:14:49 +0100 |
commit | c84938addc2498ab80f5d2ffc78e74a461d6cb18 (patch) | |
tree | ea95e1a72ef1372db2ef914445a22cef1883c1c8 | |
parent | 4050e4790ecbf88787c259d80bae9eb396e547a7 (diff) | |
parent | 380672e6e96e58a34905b9a2c07c8a35b41d7ae9 (diff) | |
download | slop-v3.tar.gz |
Merge pull request #152 from squarism/masterv3
add strict mode / rescue example to README
-rw-r--r-- | README.md | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -93,6 +93,23 @@ opts[:range] #=> 1..10 opts[:range] #=> 1..10 ``` +Strict Flags +------------ +If you want to print `--help` automatically when a required flag is left out, you can rescue `Slop::Error` like so: + +``` +opts = Slop.new strict: true do + # options here... +end + +begin + opts.parse +rescue Slop::Error => e + puts e.message + puts opts # print help +end +``` + Autocreate ---------- |