[#BloombergLP-balcl-CommandLine-parse-0c]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/balcl.adoc[balcl]::xref:BloombergLP/balcl/CommandLine.adoc[CommandLine]::parse
:relfileprefix: ../../../
:mrdocs:

Parse the command&hyphen;line arguments in `argv` of length `argc`&period;

== Synopsis

Declared in `&lt;balcl&lowbar;commandline&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
int
parse(
    int argc,
    char const const* argv[]);
----

== Description

Optionally specify an `errorStream` to which an appropriate error message is written if parsing fails&period; If `errorStream` is not specified, `bsl&colon;&colon;cerr` is used&period; Return 0 on success, and a non&hyphen;zero value otherwise&period; If an argument is not specified on the command&hyphen;line, then if the `Option` object configuration for this `CommandLine` defines an environment variable name and the runtime environment for this application has set that environment variable, then set the option to the value of the environment variable&period; Otherwise, if an option is not set by the command line, or the environment, set the option using the default value if one has been provided&period; If the option has not been set by the command line, environment, or by default, `hasValue` for the option will return `false`&period; After a successful call `isParsed()` and `isValid()` will both be `true`, and the information provided by `argv` can be viewed via the accessors&period; After an unsuccessful call `isParsed()` and `isValid()` will both be `false`&period; The behavior is undefined unless `isValid()` is `true` and `isParsed()` is `false` (i&period;e&period; the `CommandLine` was constructed in a valid state, and `parse` has not previously been called)&period;

== Return Value

0 on success, and a non&hyphen;zero value otherwise

== Parameters

[cols="1,4"]
|===
| Name| Description
| *argc*
| length of the `argv` array
| *argv*
| array of command&hyphen;line argument strings
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
