summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOndrej Holy <oholy@redhat.com>2018-05-25 17:04:56 +0200
committerOndrej Holy <oholy@redhat.com>2018-05-26 09:18:28 +0200
commit5f459d132cc235e21d56fc9d7bffafdf3212050b (patch)
treed884fe766dd092691d5606e6efb1bb9c0064e485
parentb3bbabf10278235fcf5d17f747b7e64a8e4431f7 (diff)
downloadglib-wip/oholy/gio-tool-arguments.tar.gz
gio-tool: Print help if no arguments are givenwip/oholy/gio-tool-arguments
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.
-rw-r--r--gio/gio-tool-mount.c10
-rw-r--r--gio/gio-tool-trash.c13
2 files changed, 17 insertions, 6 deletions
diff --git a/gio/gio-tool-mount.c b/gio/gio-tool-mount.c
index fab32694c..2797d94b6 100644
--- a/gio/gio-tool-mount.c
+++ b/gio/gio-tool-mount.c
@@ -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);
diff --git a/gio/gio-tool-trash.c b/gio/gio-tool-trash.c
index aa4d8c3b3..7d00a5d14 100644
--- a/gio/gio-tool-trash.c
+++ b/gio/gio-tool-trash.c
@@ -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;
@@ -124,14 +122,21 @@ handle_trash (int argc, char *argv[], gboolean do_help)
g_object_unref (file);
}
}
-
- if (empty)
+ else if (empty)
{
GFile *file;
file = g_file_new_for_uri ("trash:");
delete_trash_file (file, FALSE, TRUE);
g_object_unref (file);
}
+ else
+ {
+ show_help (context, _("No locations given"));
+ g_option_context_free (context);
+ return 1;
+ }
+
+ g_option_context_free (context);
return retval;
}