summaryrefslogtreecommitdiff
path: root/programs
diff options
context:
space:
mode:
authorChristian Kellner <gicmo@gnome.org>2010-02-18 17:07:09 +0100
committerChristian Kellner <gicmo@gnome.org>2010-02-18 17:25:56 +0100
commit9ae416270a036a1be4c7bb28fbb934d46e68123d (patch)
treece0ea880ee0b01202f49169c143d3d1dcc870a1e /programs
parent79baa66e0c7cae05620187948c960bbe04f731a6 (diff)
downloadgvfs-9ae416270a036a1be4c7bb28fbb934d46e68123d.tar.gz
gvfs-copy: Fix cmd-line help and error reporting
Partly fixes bug #593045
Diffstat (limited to 'programs')
-rw-r--r--programs/gvfs-copy.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/programs/gvfs-copy.c b/programs/gvfs-copy.c
index 40f43e01..6d6ccc0f 100644
--- a/programs/gvfs-copy.c
+++ b/programs/gvfs-copy.c
@@ -81,6 +81,19 @@ show_progress (goffset current_num_bytes,
g_free (size);
}
+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[])
@@ -98,10 +111,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 - copy 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)
{
@@ -116,7 +128,7 @@ main (int argc, char *argv[])
if (argc <= 2)
{
- g_printerr (_("Missing operand\n"));
+ show_help (context, _("Missing operand\n"));
return 1;
}
@@ -124,7 +136,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;
}
@@ -134,10 +146,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]);