OptionParser.parse-exclamation-mark
You're seeing just the function
parse-exclamation-mark
, go back to OptionParser module for more information.
Specs
The same as parse/2
but raises an OptionParser.ParseError
exception if any invalid options are given.
If there are no errors, returns a {parsed, rest}
tuple where:
parsed
is the list of parsed switches (same as inparse/2
)rest
is the list of arguments (same as inparse/2
)
Examples
iex> OptionParser.parse!(["--debug", "path/to/file"], strict: [debug: :boolean])
{[debug: true], ["path/to/file"]}
iex> OptionParser.parse!(["--limit", "xyz"], strict: [limit: :integer])
** (OptionParser.ParseError) 1 error found!
--limit : Expected type integer, got "xyz"
iex> OptionParser.parse!(["--unknown", "xyz"], strict: [])
** (OptionParser.ParseError) 1 error found!
--unknown : Unknown option
iex> OptionParser.parse!(
...> ["-l", "xyz", "-f", "bar"],
...> switches: [limit: :integer, foo: :integer],
...> aliases: [l: :limit, f: :foo]
...> )
** (OptionParser.ParseError) 2 errors found!
-l : Expected type integer, got "xyz"
-f : Expected type integer, got "bar"