summaryrefslogtreecommitdiff
path: root/programs
diff options
context:
space:
mode:
authorChristian Kellner <gicmo@gnome.org>2010-02-18 17:26:08 +0100
committerChristian Kellner <gicmo@gnome.org>2010-02-18 17:26:08 +0100
commitb7cf5c8aab80aa43eca9b9603bc76483f847d288 (patch)
tree3ff8af77e4a3a8d20924fe5f6620067ecbc18c01 /programs
parent9ae416270a036a1be4c7bb28fbb934d46e68123d (diff)
downloadgvfs-b7cf5c8aab80aa43eca9b9603bc76483f847d288.tar.gz
gvfs-move: Fix cmd-line help and error reporting
Partly fixes bug #593045
Diffstat (limited to 'programs')
-rw-r--r--programs/gvfs-move.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/programs/gvfs-move.c b/programs/gvfs-move.c
index ae8a3fe6..7d7114be 100644
--- a/programs/gvfs-move.c
+++ b/programs/gvfs-move.c
@@ -69,6 +69,19 @@ show_progress (goffset current_num_bytes,
current_num_bytes, total_num_bytes);
}
+static void
+show_help (GOptionContext *context, const char *error)
+{
+ char *help;
+
+ if (error)
+ g_printerr (_("Error: %s"), error);
+
+ help = g_option_context_get_help (context, TRUE, NULL);
+ g_printerr ("%s", help);
+ g_free (help);
+ g_option_context_free (context);
+}
int
main (int argc, char *argv[])
@@ -86,10 +99,9 @@ main (int argc, char *argv[])
g_type_init ();
error = NULL;
- context = g_option_context_new (_("- output files at <location>"));
+ context = g_option_context_new (_("SOURCE... DEST - move file(s) from SOURCE to DEST"));
g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
g_option_context_parse (context, &argc, &argv, &error);
- g_option_context_free (context);
if (error != NULL)
{
@@ -104,7 +116,7 @@ main (int argc, char *argv[])
if (argc <= 2)
{
- g_printerr (_("Missing operand\n"));
+ show_help (context, _("Missing operand\n"));
return 1;
}
@@ -112,7 +124,7 @@ main (int argc, char *argv[])
if (no_target_directory && argc > 3)
{
- g_printerr (_("Too many arguments\n"));
+ show_help (context, _("Too many arguments\n"));
g_object_unref (dest);
return 1;
}
@@ -122,10 +134,13 @@ main (int argc, char *argv[])
if (!dest_is_dir && argc > 3)
{
g_printerr (_("Target %s is not a directory\n"), argv[argc-1]);
+ show_help (context, NULL);
g_object_unref (dest);
return 1;
}
+ g_option_context_free (context);
+
for (i = 1; i < argc - 1; i++)
{
source = g_file_new_for_commandline_arg (argv[i]);