Struct

GLibOptionContext

Description [src]

struct GOptionContext {
  /* No available fields */
}

A GOptionContext struct defines which options are accepted by the commandline option parser. The struct has only private fields and should not be directly accessed.

Functions

g_option_context_new

Creates a new option context.

Available since: 2.6

Instance methods

g_option_context_add_group

Adds a GOptionGroup to the context, so that parsing with context will recognize the options in the group. Note that this will take ownership of the group and thus the group should not be freed.

Available since: 2.6

g_option_context_add_main_entries

A convenience function which creates a main group if it doesn’t exist, adds the entries to it and sets the translation domain.

Available since: 2.6

g_option_context_free

Frees context and all the groups which have been added to it.

Available since: 2.6

g_option_context_get_description

Returns the description. See g_option_context_set_description().

Available since: 2.12

g_option_context_get_help

Returns a formatted, translated help text for the given context. To obtain the text produced by --help, call g_option_context_get_help (context, TRUE, NULL). To obtain the text produced by --help-all, call g_option_context_get_help (context, FALSE, NULL). To obtain the help text for an option group, call g_option_context_get_help (context, FALSE, group).

Available since: 2.14

g_option_context_get_help_enabled

Returns whether automatic --help generation is turned on for context. See g_option_context_set_help_enabled().

Available since: 2.6

g_option_context_get_ignore_unknown_options

Returns whether unknown options are ignored or not. See g_option_context_set_ignore_unknown_options().

Available since: 2.6

g_option_context_get_main_group

Returns a pointer to the main group of context.

Available since: 2.6

g_option_context_get_strict_posix

Returns whether strict POSIX code is enabled.

Available since: 2.44

g_option_context_get_summary

Returns the summary. See g_option_context_set_summary().

Available since: 2.12

g_option_context_parse

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.

Available since: 2.6

g_option_context_parse_strv

Parses the command line arguments.

Available since: 2.40

g_option_context_set_description

Adds a string to be displayed in --help output after the list of options. This text often includes a bug reporting address.

Available since: 2.12

g_option_context_set_help_enabled

Enables or disables automatic generation of --help output. By default, g_option_context_parse() recognizes --help, -h, -?, --help-all and --help-groupname and creates suitable output to stdout.

Available since: 2.6

g_option_context_set_ignore_unknown_options

Sets whether to ignore unknown options or not. If an argument is ignored, it is left in the argv array after parsing. By default, g_option_context_parse() treats unknown options as error.

Available since: 2.6

g_option_context_set_main_group

Sets a GOptionGroup as main group of the context. This has the same effect as calling g_option_context_add_group(), the only difference is that the options in the main group are treated differently when generating --help output.

Available since: 2.6

g_option_context_set_strict_posix

Sets strict POSIX mode.

Available since: 2.44

g_option_context_set_summary

Adds a string to be displayed in --help output before the list of options. This is typically a summary of the program functionality.

Available since: 2.12

g_option_context_set_translate_func

Sets the function which is used to translate the contexts user-visible strings, for --help output. If func is NULL, strings are not translated.

Available since: 2.12

g_option_context_set_translation_domain

A convenience function to use gettext() for translating user-visible strings.

Available since: 2.12