summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLee Jarvis <ljjarvis@gmail.com>2014-10-08 09:14:49 +0100
committerLee Jarvis <ljjarvis@gmail.com>2014-10-08 09:14:49 +0100
commitc84938addc2498ab80f5d2ffc78e74a461d6cb18 (patch)
treeea95e1a72ef1372db2ef914445a22cef1883c1c8
parent4050e4790ecbf88787c259d80bae9eb396e547a7 (diff)
parent380672e6e96e58a34905b9a2c07c8a35b41d7ae9 (diff)
downloadslop-v3.tar.gz
Merge pull request #152 from squarism/masterv3
add strict mode / rescue example to README
-rw-r--r--README.md17
1 files changed, 17 insertions, 0 deletions
diff --git a/README.md b/README.md
index e535970..40dbdf4 100644
--- a/README.md
+++ b/README.md
@@ -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
----------