extensions-tool: Add common option to silence errors
Error reporting is useful when used interactively, but often undesirable when used in scripts. Account for that with a common --quiet option, which is more convenient than redirection stderr to /dev/null. https://gitlab.gnome.org/GNOME/gnome-shell/issues/2391
This commit is contained in:
@ -49,6 +49,39 @@ extension_state_to_string (ExtensionState state)
|
||||
return "UNKNOWN";
|
||||
}
|
||||
|
||||
static void
|
||||
print_nothing (const char *message)
|
||||
{
|
||||
}
|
||||
|
||||
static gboolean
|
||||
quiet_cb (const gchar *option_name,
|
||||
const gchar *value,
|
||||
gpointer data,
|
||||
GError **error)
|
||||
{
|
||||
g_set_printerr_handler (print_nothing);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
GOptionGroup *
|
||||
get_option_group ()
|
||||
{
|
||||
GOptionEntry entries[] = {
|
||||
{ .long_name = "quiet", .short_name = 'q',
|
||||
.description = _("Do not print error messages"),
|
||||
.arg = G_OPTION_ARG_CALLBACK, .arg_data = &quiet_cb,
|
||||
.flags = G_OPTION_FLAG_NO_ARG | G_OPTION_FLAG_IN_MAIN },
|
||||
{ NULL }
|
||||
};
|
||||
GOptionGroup *group;
|
||||
|
||||
group = g_option_group_new ("Common", "common options", "common options", NULL, NULL);
|
||||
g_option_group_add_entries (group, entries);
|
||||
|
||||
return group;
|
||||
}
|
||||
|
||||
void
|
||||
show_help (GOptionContext *context, const char *message)
|
||||
{
|
||||
|
Reference in New Issue
Block a user