Method
GLibOptionContextparse
since: 2.6
Declaration [src]
gboolean
g_option_context_parse (
GOptionContext* context,
gint* argc,
gchar*** argv,
GError** error
)
Description [src]
Parses the command line arguments, recognizing options
which have been added to context
. A side-effect of
calling this function is that g_set_prgname()
will be called.
If the parsing is successful, any parsed arguments are
removed from the array and argc
and argv
are updated
accordingly. A ‘—’ option is stripped from argv
unless there are unparsed options before and after it,
or some of the options after it start with ‘-‘. In case
of an error, argc
and argv
are left unmodified.
If automatic --help
support is enabled
(see g_option_context_set_help_enabled()), and the
argv
array contains one of the recognized help options,
this function will produce help output to stdout and
call exit (0)
.
Note that function depends on the [current locale][setlocale] for automatic character set conversion of string and filename arguments.
Available since: 2.6
Parameters
argc
-
Type:
gint*
A pointer to the number of command line arguments.
The argument will be modified by the function. The argument can be NULL
. argv
-
Type: An array of
gchar**
A pointer to the array of command line arguments.
The argument will be modified by the function. The argument can be NULL
.The length of the array is specified in the argc
argument.The caller of the method takes ownership of the returned data, and is responsible for freeing it. Each element is a NUL terminated UTF-8 string. error
-
Type:
GError **
The return location for a recoverable error.
The argument can be NULL
.If the return location is not NULL
, then you must initialize it to aNULL
GError*
.The argument will be left initialized to NULL
by the method if there are no errors.In case of error, the argument will be set to a newly allocated GError
; the caller will take ownership of the data, and be responsible for freeing it.