gio-tool: Print help if no arguments are given

Help is usually printed from tools if no arguments are given and there
is not default action. However "gio mount" and "gio trash" just silently
return. Let's print "No locations given" error and show help consistently.
This commit is contained in:
Ondrej Holy 2018-05-25 17:04:56 +02:00
parent bc365c9b4e
commit 2cb2a617f1
2 changed files with 17 additions and 4 deletions

View File

@ -1160,8 +1160,6 @@ handle_mount (int argc, char *argv[], gboolean do_help)
return 1;
}
g_option_context_free (context);
main_loop = g_main_loop_new (NULL, FALSE);
if (mount_list)
@ -1186,6 +1184,14 @@ handle_mount (int argc, char *argv[], gboolean do_help)
g_object_unref (file);
}
}
else
{
show_help (context, _("No locations given"));
g_option_context_free (context);
return 1;
}
g_option_context_free (context);
if (outstanding_mounts > 0)
g_main_loop_run (main_loop);

View File

@ -101,8 +101,6 @@ handle_trash (int argc, char *argv[], gboolean do_help)
return 1;
}
g_option_context_free (context);
if (argc > 1)
{
int i;
@ -133,5 +131,14 @@ handle_trash (int argc, char *argv[], gboolean do_help)
g_object_unref (file);
}
if (argc == 1 && !empty)
{
show_help (context, _("No locations given"));
g_option_context_free (context);
return 1;
}
g_option_context_free (context);
return retval;
}