diff options
author | William Woodruff <william@tuffbizz.com> | 2017-09-29 18:31:28 -0400 |
---|---|---|
committer | William Woodruff <william@tuffbizz.com> | 2017-09-29 18:55:49 -0400 |
commit | 311cb9fbe94fe09c0dc08a52f5bff169529960ba (patch) | |
tree | 8eb7c8bcba2f7210e47b393dd200c2423dab82c0 /README.md | |
parent | ec47929b2ffe986b13701c30f1bbe3018593bc6c (diff) | |
download | slop-311cb9fbe94fe09c0dc08a52f5bff169529960ba.tar.gz |
Support for required options
This commit introduces support for required options,
which are options that cause the parser to raise
a `MissingRequiredOption` exception if not present.
Options can be marked as required by passing
`required: true` in their configuration, and any errors
caused by missing required options can be suppressed via
`suppress_errors: true`.
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 2 |
1 files changed, 2 insertions, 0 deletions
@@ -20,6 +20,7 @@ Usage opts = Slop.parse do |o| o.string '-h', '--host', 'a hostname' o.integer '--port', 'custom port', default: 80 + o.string '-l', '--login', required: true o.bool '-v', '--verbose', 'enable verbose mode' o.bool '-q', '--quiet', 'suppress output (quiet mode)' o.bool '-c', '--check-ssl-certificate', 'check SSL certificate for host' @@ -197,6 +198,7 @@ Slop will raise errors for the following: * An option used without an argument when it expects one: `Slop::MissingArgument` * An option used that Slop doesn't know about: `Slop::UnknownOption` +* An option marked as `required` when not provided: `Slop::MissingRequiredOption` These errors inherit from `Slop::Error`, so you can rescue them all. Alternatively you can suppress these errors with the `suppress_errors` config |