static GOptionGroup* config_options_group_mu (void) { GOptionGroup *og; GOptionEntry entries[] = { {"debug", 'd', 0, G_OPTION_ARG_NONE, &MU_CONFIG.debug, "print debug output to standard error (false)", NULL}, {"quiet", 'q', 0, G_OPTION_ARG_NONE, &MU_CONFIG.quiet, "don't give any progress information (false)", NULL}, {"version", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.version, "display version and copyright information (false)", NULL}, {"muhome", 0, 0, G_OPTION_ARG_FILENAME, &MU_CONFIG.muhome, "specify an alternative mu directory", "<dir>"}, {"log-stderr", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.log_stderr, "log to standard error (false)", NULL}, {"nocolor", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.nocolor, "don't use ANSI-colors in output (false)", NULL}, {"verbose", 'v', 0, G_OPTION_ARG_NONE, &MU_CONFIG.verbose, "verbose output (false)", NULL}, {G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY, &MU_CONFIG.params, "parameters", NULL}, {NULL, 0, 0, 0, NULL, NULL, NULL} }; og = g_option_group_new("mu", "general mu options", "", NULL, NULL); g_option_group_add_entries(og, entries); return og; }
/* * init options context */ static GOptionContext * init_options( void ) { GOptionContext *context; gchar* description; GOptionGroup *misc_group; context = g_option_context_new( _( "Execute an action on the specified target." )); g_option_context_set_translation_domain( context, GETTEXT_PACKAGE ); #ifdef ENABLE_NLS bindtextdomain( GETTEXT_PACKAGE, MATELOCALEDIR ); # ifdef HAVE_BIND_TEXTDOMAIN_CODESET bind_textdomain_codeset( GETTEXT_PACKAGE, "UTF-8" ); # endif textdomain( GETTEXT_PACKAGE ); g_option_context_add_main_entries( context, entries, GETTEXT_PACKAGE ); #else g_option_context_add_main_entries( context, entries, NULL ); #endif description = console_cmdline_get_description(); g_option_context_set_description( context, description ); g_free( description ); misc_group = g_option_group_new( "misc", _( "Miscellaneous options" ), _( "Miscellaneous options" ), NULL, NULL ); g_option_group_add_entries( misc_group, misc_entries ); g_option_group_set_translation_domain( misc_group, GETTEXT_PACKAGE ); g_option_context_add_group( context, misc_group ); return( context ); }
void tg_option_tests() { GOptionContext *context; GOptionContext *context1;//for testing set main group GOptionContext *context2;//for testing add group gboolean retval; GError *error = NULL; gchar **argv; int argc; gchar **argv1; int argc1; GOptionEntry entries [] = { { "test", 0, 0, G_OPTION_ARG_INT, &arg_test1_int, "test_description", "test_arg" }, { NULL } }; GOptionEntry entries1 [] = { { "try", 0, 0, G_OPTION_ARG_INT, &arg_test1_int, "try_description", "try_arg" }, { NULL } }; GOptionEntry entries2 [] = { { "again", 0, 0, G_OPTION_ARG_INT, &arg_test1_int, "again_description", "again_arg" }, { NULL } }; GOptionGroup *main_group; context = g_option_context_new (NULL); context1 = g_option_context_new (NULL); context2 = g_option_context_new (NULL); g_option_context_add_main_entries (context, entries, NULL); g_option_context_add_main_entries (context2, entries, NULL); main_group = g_option_context_get_main_group (context); //Testing g_option_context_set_main_group with another context-context1 g_option_group_add_entries (main_group,entries1); g_option_context_set_main_group(context1,main_group); //Testing g_option_context_set_help_enabled //and g_option_context_get_help_enabled //and g_option_context_get_ignore_unknown_options g_option_context_set_help_enabled(context,TRUE); g_assert(g_option_context_get_help_enabled(context)); g_assert(!g_option_context_get_ignore_unknown_options(context)); /* Now try parsing on context1*/ argv = split_string ("program --try 20 --try 30", &argc); retval = g_option_context_parse (context1, &argc, &argv, &error); g_assert (retval); /* Last arg specified is the one that should be stored */ g_assert (arg_test1_int == 30); g_option_group_set_error_hook (main_group, error_func); argv = split_string ("program --none 20 --none 30", &argc); retval = g_option_context_parse (context1, &argc, &argv, &error); g_strfreev (argv); g_option_context_free (context); }
void msg_add_option_group(GOptionContext *ctx) { GOptionGroup *group; group = g_option_group_new("log", "Log options", "Log options", NULL, NULL); g_option_group_add_entries(group, msg_option_entries); g_option_context_add_group(ctx, group); }
int main (int argc, char* argv[]) { const UgOptionEntry* uoentry; UgDataset* dataset; UgetCommon* common; UgPlugin* plugin; GOptionContext* context; GOptionGroup* group; GError* error = NULL; #ifdef _WIN32 // curl_global_init() will do this WSADATA WSAData; WSAStartup (MAKEWORD (2, 2), &WSAData); #endif uglib_init (); // parse command-line options context = g_option_context_new ("[URL]"); group = g_option_group_new (NULL, NULL, NULL, NULL, NULL); uoentry = ug_option_get_main_entry (); g_option_group_add_entries (group, uoentry->entry); g_option_context_set_main_group (context, group); if (g_option_context_parse (context, &argc, &argv, &error) == FALSE) { g_print ("Option parsing failed : %s\n", error->message); exit (EXIT_FAILURE); // EXIT_FAILURE == 1 } // get URL from remained arguments if (argc == 1) { g_print ("%s", g_option_context_get_help (context, TRUE, NULL)); exit (EXIT_FAILURE); // EXIT_FAILURE == 1 } dataset = ug_dataset_new (); ug_option_entry_get (uoentry, dataset); common = ug_dataset_realloc (dataset, UgetCommonInfo, 0); common->url = g_strdup (argv[1]); plugin = ug_plugin_new_by_data (dataset); ug_dataset_unref (dataset); if (plugin) { ug_plugin_set_state (plugin, UG_STATE_ACTIVE); while (ug_plugin_dispatch (plugin, plugin_callback, NULL)) ug_plugin_delay (plugin, 1000); ug_plugin_unref (plugin); } uglib_finalize (); #ifdef _WIN32 WSACleanup (); #endif return EXIT_SUCCESS; // EXIT_SUCCESS == 0 }
GOptionGroup* ppg_prefs_get_option_group (void) { GOptionGroup *group; group = g_option_group_new("prefs", "Application preferences", "", NULL, NULL); g_option_group_add_entries(group, entries); return group; }
GOptionGroup* PlaybackController::getOptionGroup() { GOptionGroup* group = g_option_group_new( "playback", "Options for the Playback Controller", "The Playback Controller plays music from the Gemini database", NULL, NULL ); g_option_group_add_entries( group, options ); return group; }
GOptionGroup *spice_cmdline_get_option_group(void) { if (spice_group == NULL) { spice_group = g_option_group_new("spice", _("Spice Options:"), _("Show spice Options"), NULL, NULL); g_option_group_add_entries(spice_group, spice_entries); } return spice_group; }
/** * gnm_get_option_group: (skip) * * Returns a #GOptionGroup for the commandline arguments recognized * by libspreadsheet. You should add this group to your #GOptionContext with * g_option_context_add_group(), if you are using g_option_context_parse() to * parse your commandline arguments. * * Returns a #GOptionGroup for the commandline arguments recognized * by libspreadsheet * * Since: 1.8 **/ GOptionGroup * gnm_get_option_group (void) { GOptionGroup *group = g_option_group_new ("libspreadsheet", _("Gnumeric Options"), _("Show Gnumeric Options"), NULL, NULL); g_option_group_add_entries (group, libspreadsheet_options); g_option_group_set_translation_domain (group, GETTEXT_PACKAGE); g_option_group_set_parse_hooks (group, NULL, &cb_gnm_option_group_post_parse); return group; }
static GOptionGroup* config_options_group_verify (void) { GOptionGroup *og; og = g_option_group_new("verify", "Options for the 'verify' command", "", NULL, NULL); g_option_group_add_entries(og, crypto_option_entries()); return og; }
GOptionGroup *spice_cmdline_get_option_group(void) { GOptionGroup *grp; grp = g_option_group_new("spice", _("Spice connection options:"), _("Show Spice options"), NULL, NULL); g_option_group_add_entries(grp, spice_entries); return grp; }
static gboolean parse_cmdline (struct config *cfg, gint *argc, gchar **argv[], GError **error) { GOptionContext *context; GOptionEntry entries[] = { { "category", 'c', 0, G_OPTION_ARG_CALLBACK, cmdline_category, "Set the item's category;\n\t\t" "CATEGORY must be app, comm, system or hardware", "CATEGORY" }, { "title", 't', 0, G_OPTION_ARG_STRING, &cfg->title, "Set TITLE as the item's title", "TITLE" }, { "status", 's', 0, G_OPTION_ARG_CALLBACK, cmdline_status, "Set the item's status;\n\t\t" "STATUS must be active, passive or attention", "STATUS" }, { "icon", 'i', 0, G_OPTION_ARG_CALLBACK, cmdline_icon_name, "Use NAME as icon name for (main) icon", "NAME" }, { "pixbuf", 'I', 0, G_OPTION_ARG_CALLBACK, cmdline_icon_pixbuf, "Load FILE as icon for (main) icon", "FILE" }, { "attention-icon", 'a', 0, G_OPTION_ARG_CALLBACK, cmdline_icon_name, "Use NAME as icon name for attention icon", "NAME" }, { "attention-pixbuf", 'A', 0, G_OPTION_ARG_CALLBACK, cmdline_icon_pixbuf, "Load FILE as icon for attention icon", "FILE" }, { "overlay-icon", 'o', 0, G_OPTION_ARG_CALLBACK, cmdline_icon_name, "Use NAME as icon name for overlay icon", "NAME" }, { "overlay-pixbuf", 'O', 0, G_OPTION_ARG_CALLBACK, cmdline_icon_pixbuf, "Load FILE as icon for overlay icon", "FILE" }, { "tooltip-icon", 'l', 0, G_OPTION_ARG_CALLBACK, cmdline_icon_name, "Use NAME as icon name for tooltip icon", "NAME" }, { "tooltip-pixbuf", 'L', 0, G_OPTION_ARG_CALLBACK, cmdline_icon_pixbuf, "Load FILE as icon for tooltip icon", "FILE" }, { "tooltip", 'T', 0, G_OPTION_ARG_STRING, &cfg->tooltip_title, "Set TITLE as title of the item's tooltip", "TITLE" }, { "tooltip-body", 'b', 0, G_OPTION_ARG_STRING, &cfg->tooltip_body, "Set TEXT as body of the item's tooltip", "TEXT" }, { "item-is-menu", 'M', 0, G_OPTION_ARG_NONE, &cfg->item_is_menu, "Whether the item only supports context menu or not", NULL}, #ifdef USE_DBUSMENU { "dbus-menu", 'm', 0, G_OPTION_ARG_NONE, &cfg->menu, "Whether menu should be exposed via dbusmenu or not", NULL }, #endif { NULL } }; GOptionGroup *group; context = g_option_context_new (""); group = g_option_group_new ("example", "example", "app options", cfg, NULL); g_option_group_add_entries (group, entries); g_option_context_set_main_group (context, group); if (!g_option_context_parse (context, argc, argv, error)) return FALSE; return TRUE; }
/** * brasero_burn_library_get_option_group: * * Returns a GOptionGroup for the commandline arguments recognized by libbrasero-burn. * You should add this to your GOptionContext if your are using g_option_context_parse () * to parse your commandline arguments. * * Return value: a #GOptionGroup * **/ GOptionGroup * brasero_burn_library_get_option_group (void) { GOptionGroup *group; group = g_option_group_new ("brasero-burn", N_("Brasero media burning library"), N_("Display options for Brasero-burn library"), NULL, NULL); g_option_group_add_entries (group, options); return group; }
/** * g_option_context_add_main_entries: * @context: a #GOptionContext * @entries: a %NULL-terminated array of #GOptionEntry<!-- -->s * @translation_domain: a translation domain to use for translating * the <option>--help</option> output for the options in @entries * with gettext(), or %NULL * * A convenience function which creates a main group if it doesn't * exist, adds the @entries to it and sets the translation domain. * * Since: 2.6 **/ void g_option_context_add_main_entries (GOptionContext *context, const GOptionEntry *entries, const gchar *translation_domain) { g_return_if_fail (entries != NULL); if (!context->main_group) context->main_group = g_option_group_new (NULL, NULL, NULL, NULL, NULL); g_option_group_add_entries (context->main_group, entries); g_option_group_set_translation_domain (context->main_group, translation_domain); }
/** * gegl_get_option_group: * * Returns a #GOptionGroup for the commandline arguments recognized * by GEGL. You should add this group to your #GOptionContext * with g_option_context_add_group(), if you are using * g_option_context_parse() to parse your commandline arguments. * * Returns a #GOptionGroup for the commandline arguments recognized by GEGL. */ GOptionGroup * gegl_get_option_group (void) { GOptionGroup *group; group = g_option_group_new ("gegl", "GEGL Options", "Show GEGL Options", NULL, NULL); g_option_group_add_entries (group, cmd_entries); g_option_group_set_parse_hooks (group, NULL, gegl_post_parse_hook); return group; }
static GOptionGroup * test_get_option_group (void) { GOptionGroup *group; group = g_option_group_new ("test", "Test options", "Show Test options", NULL, NULL); g_option_group_add_entries (group, test_entries); return group; }
/** * rejilla_media_get_option_group: * * Returns a GOptionGroup for the commandline arguments recognized by librejilla-media. * You should add this to your GOptionContext if your are using g_option_context_parse () * to parse your commandline arguments. * * Return value: a #GOptionGroup * **/ GOptionGroup * rejilla_media_get_option_group (void) { GOptionGroup *group; group = g_option_group_new ("rejilla-media", N_("Rejilla optical media library"), N_("Display options for Rejilla media library"), NULL, NULL); g_option_group_add_entries (group, options); return group; }
int main(int argc, char *argv[]) { GError *error = NULL; GOptionContext *context; GOptionGroup *group_fuse; gchar *cryptofs_cfg; gchar *cipheralgo, *mdalgo; long int fileblocksize; long int num_of_salts; umask(0); g_slice_set_config(G_SLICE_CONFIG_ALWAYS_MALLOC, TRUE); help_fuse_argv[0] = argv[0]; context = g_option_context_new ("[FUSE OPTIONS...]"); g_option_context_set_ignore_unknown_options(context, TRUE); g_option_context_add_main_entries (context, entries, NULL); group_fuse = g_option_group_new("fuse", "x", SHOW_FUSE_OPTIONS, NULL, NULL); g_option_group_add_entries(group_fuse, entries_fuse); g_option_group_set_translate_func(group_fuse, help_fuse, NULL, NULL); g_option_context_add_group(context, group_fuse); g_option_context_parse (context, &argc, &argv, &error); g_option_context_free(context); if (rootpath == NULL) { fprintf(stderr, "No path for encrypted directory specified (see --help)\n"); exit(1); } if (!g_path_is_absolute(rootpath)) { gchar *oldpath = rootpath; gchar *curpath = g_get_current_dir(); rootpath = g_strconcat(curpath, G_DIR_SEPARATOR_S, rootpath, NULL); g_free(curpath); g_free(oldpath); } cryptofs_cfg = g_strconcat(rootpath, G_DIR_SEPARATOR_S, CONFIGFILE, NULL); if (!read_config(cryptofs_cfg, &cipheralgo, &mdalgo, &fileblocksize, &num_of_salts)) { fprintf(stderr, "Could not read config for encrypted directory\n" "Check that %s/" CONFIGFILE " is available and correct\n", rootpath); exit(1); } g_free(cryptofs_cfg); fs_init(rootpath, crypto_create_global_ctx_default(cipheralgo, mdalgo, fileblocksize, num_of_salts)); return fuse_main(argc, argv, fs_get_fuse_operations(), NULL); }
GOptionGroup * qmicli_pbm_get_option_group (void) { GOptionGroup *group; group = g_option_group_new ("pbm", "PBM options", "Show Phonebook Management options", NULL, NULL); g_option_group_add_entries (group, entries); return group; }
GOptionGroup * mmcli_modem_time_get_option_group (void) { GOptionGroup *group; group = g_option_group_new ("time", "Time options", "Show Time options", NULL, NULL); g_option_group_add_entries (group, entries); return group; }
/** * vips_get_option_group: (skip) * * vips_get_option_group() returns a GOptionGroup containing various VIPS * command-line options. It can be used with GOption to help * parse argc/argv. * * See also: vips_version(), vips_guess_prefix(), * vips_guess_libdir(), vips_init(). * * Returns: a GOptionGroup for VIPS, see GOption */ GOptionGroup * vips_get_option_group( void ) { static GOptionGroup *option_group = NULL; if( !option_group ) { option_group = g_option_group_new( "vips", _( "VIPS Options" ), _( "Show VIPS options" ), NULL, NULL ); g_option_group_add_entries( option_group, option_entries ); } return( option_group ); }
GOptionGroup * mmcli_modem_cdma_get_option_group (void) { GOptionGroup *group; group = g_option_group_new ("cdma", "CDMA options", "Show CDMA related options", NULL, NULL); g_option_group_add_entries (group, entries); return group; }
GOptionGroup * mmcli_modem_firmware_get_option_group (void) { GOptionGroup *group; group = g_option_group_new ("firmware", "Firmware options", "Show Firmware options", NULL, NULL); g_option_group_add_entries (group, entries); return group; }
GOptionGroup * mmcli_modem_simple_get_option_group (void) { GOptionGroup *group; group = g_option_group_new ("simple", "Simple options", "Show Simple options", NULL, NULL); g_option_group_add_entries (group, entries); return group; }
GOptionGroup * mmcli_modem_location_get_option_group (void) { GOptionGroup *group; group = g_option_group_new ("location", "Location options", "Show Location options", NULL, NULL); g_option_group_add_entries (group, entries); return group; }
GOptionGroup * qmicli_dms_get_option_group (void) { GOptionGroup *group; group = g_option_group_new ("dms", "DMS options", "Show Device Management Service options", NULL, NULL); g_option_group_add_entries (group, entries); return group; }
GOptionGroup * mmcli_modem_messaging_get_option_group (void) { GOptionGroup *group; group = g_option_group_new ("messaging", "Messaging options", "Show Messaging options", NULL, NULL); g_option_group_add_entries (group, entries); return group; }
static GOptionGroup* config_options_group_find (void) { GOptionGroup *og; GOptionEntry entries[] = { {"fields", 'f', 0, G_OPTION_ARG_STRING, &MU_CONFIG.fields, "fields to display in the output", "<fields>"}, {"sortfield", 's', 0, G_OPTION_ARG_STRING, &MU_CONFIG.sortfield, "field to sort on", "<field>"}, {"maxnum", 'n', 0, G_OPTION_ARG_INT, &MU_CONFIG.maxnum, "number of entries to display in the output", "<number>"}, {"threads", 't', 0, G_OPTION_ARG_NONE, &MU_CONFIG.threads, "show message threads", NULL}, {"bookmark", 'b', 0, G_OPTION_ARG_STRING, &MU_CONFIG.bookmark, "use a bookmarked query", "<bookmark>"}, {"reverse", 'z', 0, G_OPTION_ARG_NONE, &MU_CONFIG.reverse, "sort in reverse (descending) order (z -> a)", NULL}, {"skip-dups", 'u', 0, G_OPTION_ARG_NONE, &MU_CONFIG.skip_dups, "show only the first of messages duplicates (false)", NULL}, {"include-related", 'r', 0, G_OPTION_ARG_NONE, &MU_CONFIG.include_related, "include related messages in results (false)", NULL}, {"linksdir", 0, 0, G_OPTION_ARG_STRING, &MU_CONFIG.linksdir, "output as symbolic links to a target maildir", "<dir>"}, {"clearlinks", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.clearlinks, "clear old links before filling a linksdir (false)", NULL}, {"format", 'o', 0, G_OPTION_ARG_STRING, &MU_CONFIG.formatstr, "output format ('plain'(*), 'links', 'xml'," "'sexp', 'xquery')", "<format>"}, {"summary-len", 0, 0, G_OPTION_ARG_INT, &MU_CONFIG.summary_len, "use up to <n> lines for the summary, or 0 for none (0)", "<len>"}, {"exec", 'e', 0, G_OPTION_ARG_STRING, &MU_CONFIG.exec, "execute command on each match message", "<command>"}, {"after", 0, 0, G_OPTION_ARG_INT, &MU_CONFIG.after, "only show messages whose m_time > T (t_time)", "<timestamp>"}, {NULL, 0, 0, 0, NULL, NULL, NULL} }; og = g_option_group_new("find", "Options for the 'find' command", "", NULL, NULL); g_option_group_add_entries(og, entries); return og; }
static GOptionGroup * config_options_group_view (void) { GOptionGroup *og; GOptionEntry entries[] = { {"summary-len", 0, 0, G_OPTION_ARG_INT, &MU_CONFIG.summary_len, "use up to <n> lines for the summary, or 0 for none (0)", "<len>"}, {"terminate", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.terminator, "terminate messages with ascii-0x07 (\\f, form-feed)", "<term>"}, {"format", 'o', 0, G_OPTION_ARG_STRING, &MU_CONFIG.formatstr, "output format ('plain'(*), 'sexp')", "<format>"}, {NULL, 0, 0, 0, NULL, NULL, NULL} }; og = g_option_group_new("view", "Options for the 'view' command", "", NULL, NULL); g_option_group_add_entries(og, entries); g_option_group_add_entries(og, crypto_option_entries()); return og; }
GOptionGroup * mmcli_sms_get_option_group (void) { GOptionGroup *group; /* Status options */ group = g_option_group_new ("sms", "SMS options", "Show SMS options", NULL, NULL); g_option_group_add_entries (group, entries); return group; }