OptionParser.parse_head-exclamation-mark
You're seeing just the function
parse_head-exclamation-mark
, go back to OptionParser module for more information.
Specs
The same as parse_head/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_head/2
)rest
is the list of arguments (same as inparse_head/2
)
Examples
iex> OptionParser.parse_head!(
...> ["--source", "lib", "path/to/file", "--verbose"],
...> switches: [source: :string, verbose: :boolean]
...> )
{[source: "lib"], ["path/to/file", "--verbose"]}
iex> OptionParser.parse_head!(
...> ["--number", "lib", "test/enum_test.exs", "--verbose"],
...> strict: [number: :integer]
...> )
** (OptionParser.ParseError) 1 error found!
--number : Expected type integer, got "lib"
iex> OptionParser.parse_head!(
...> ["--verbose", "--source", "lib", "test/enum_test.exs", "--unlock"],
...> strict: [verbose: :integer, source: :integer]
...> )
** (OptionParser.ParseError) 2 errors found!
--verbose : Missing argument of type integer
--source : Expected type integer, got "lib"