summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2012-06-29 13:52:16 -0400
committerMatthias Clasen <mclasen@redhat.com>2012-06-29 13:52:16 -0400
commit1a20e31a1660b1e51efc3a1bb2bb9044af209d3d (patch)
tree671ff0b1db052f2401f5272753592990931dc30a
parent99051ad3a99fb4db0444362348b7421f2e01b93d (diff)
downloadgvfs-1a20e31a1660b1e51efc3a1bb2bb9044af209d3d.tar.gz
Apply some love to the gvfs utilities
This makes the --help output more consistent across the utilities. - Capitalize parameters - Make summaries full sentences - Shorten some overlong strings - Strip . off option descriptions - Make descriptions of identical options the same - Improve error handling for option parsing Also, do proper gettext setup in all utilities.
-rw-r--r--programs/gvfs-cat.c112
-rw-r--r--programs/gvfs-copy.c30
-rw-r--r--programs/gvfs-info.c22
-rw-r--r--programs/gvfs-ls.c30
-rw-r--r--programs/gvfs-mime.c29
-rw-r--r--programs/gvfs-mkdir.c20
-rw-r--r--programs/gvfs-monitor-dir.c25
-rw-r--r--programs/gvfs-monitor-file.c25
-rw-r--r--programs/gvfs-mount.c31
-rw-r--r--programs/gvfs-move.c26
-rw-r--r--programs/gvfs-open.c22
-rw-r--r--programs/gvfs-rename.c44
-rw-r--r--programs/gvfs-rm.c26
-rw-r--r--programs/gvfs-save.c27
-rw-r--r--programs/gvfs-set-attribute.c45
-rw-r--r--programs/gvfs-trash.c26
-rw-r--r--programs/gvfs-tree.c20
17 files changed, 396 insertions, 164 deletions
diff --git a/programs/gvfs-cat.c b/programs/gvfs-cat.c
index e879d3d1..e0c201c9 100644
--- a/programs/gvfs-cat.c
+++ b/programs/gvfs-cat.c
@@ -34,8 +34,8 @@
static gchar **locations = NULL;
static GOptionEntry entries[] = {
- {G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &locations, N_("locations"), NULL},
- {NULL}
+ { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &locations, NULL, NULL },
+ { NULL }
};
static void
@@ -55,7 +55,7 @@ cat (GFile * file)
/* Translators: the first %s is the program name, the second one */
/* is the URI of the file, the third is the error message. */
g_printerr (_("%s: %s: error opening file: %s\n"),
- g_get_prgname (), g_file_get_uri (file), error->message);
+ g_get_prgname (), g_file_get_uri (file), error->message);
g_error_free (error);
return;
}
@@ -63,41 +63,41 @@ cat (GFile * file)
while (1)
{
res =
- g_input_stream_read (in, buffer, sizeof (buffer) - 1, NULL, &error);
+ g_input_stream_read (in, buffer, sizeof (buffer) - 1, NULL, &error);
if (res > 0)
- {
- ssize_t written;
-
- p = buffer;
- while (res > 0)
- {
- written = write (STDOUT_FILENO, p, res);
-
- if (written == -1 && errno != EINTR)
- {
- /* Translators: the first %s is the program name, the */
- /* second one is the URI of the file. */
- g_printerr (_("%s: %s, error writing to stdout"),
- g_get_prgname (), g_file_get_uri (file));
- goto out;
- }
- res -= written;
- p += written;
- }
- }
+ {
+ ssize_t written;
+
+ p = buffer;
+ while (res > 0)
+ {
+ written = write (STDOUT_FILENO, p, res);
+
+ if (written == -1 && errno != EINTR)
+ {
+ /* Translators: the first %s is the program name, the */
+ /* second one is the URI of the file. */
+ g_printerr (_("%s: %s, error writing to stdout"),
+ g_get_prgname (), g_file_get_uri (file));
+ goto out;
+ }
+ res -= written;
+ p += written;
+ }
+ }
else if (res < 0)
- {
- /* Translators: the first %s is the program name, the second one */
- /* is the URI of the file, the third is the error message. */
- g_printerr (_("%s: %s: error reading: %s\n"),
- g_get_prgname (), g_file_get_uri (file),
- error->message);
- g_error_free (error);
- error = NULL;
- break;
- }
+ {
+ /* Translators: the first %s is the program name, the second one */
+ /* is the URI of the file, the third is the error message. */
+ g_printerr (_("%s: %s: error reading: %s\n"),
+ g_get_prgname (), g_file_get_uri (file),
+ error->message);
+ g_error_free (error);
+ error = NULL;
+ break;
+ }
else if (res == 0)
- break;
+ break;
}
out:
@@ -108,7 +108,7 @@ cat (GFile * file)
/* Translators: the first %s is the program name, the second one */
/* is the URI of the file, the third is the error message. */
g_printerr (_("%s: %s:error closing: %s\n"),
- g_get_prgname (), g_file_get_uri (file), error->message);
+ g_get_prgname (), g_file_get_uri (file), error->message);
g_error_free (error);
}
}
@@ -120,7 +120,9 @@ main (int argc, char *argv[])
GOptionContext *context = NULL;
GFile *file;
gchar *summary;
+ gchar *description;
int i;
+ gchar *param;
setlocale (LC_ALL, "");
@@ -130,40 +132,36 @@ main (int argc, char *argv[])
g_type_init ();
- /* Translators: this message will appear immediately after the */
- /* usage string - Usage: COMMAND [OPTION]... <THIS_MESSAGE> */
- context =
- g_option_context_new (_("LOCATION... - concatenate LOCATIONS "
- "to standard output."));
-
+ param = g_strdup_printf (("%s..."), _("FILE"));
/* Translators: this message will appear after the usage string */
/* and before the list of options. */
- summary = g_strconcat (_("Concatenate files at locations and print to the "
- "standard output. Works just like the traditional "
- "cat utility, but using gvfs location instead "
- "local files: for example you can use something "
- "like smb://server/resource/file.txt as location "
- "to concatenate."),
- "\n\n",
- _("Note: just pipe through cat if you need its "
- "formatting option like -n, -T or other."), NULL);
-
+ summary = _("Concatenate files and print to the standard output.");
+ description = g_strconcat (_("gvfs-cat works just like the traditional cat utility, but using gvfs\n"
+ "locations instead of local files: for example you can use something\n"
+ "like smb://server/resource/file.txt as location."),
+ "\n\n",
+ _("Note: just pipe through cat if you need its formatting options\n"
+ "like -n, -T or other."),
+ NULL);
+
+ context = g_option_context_new (param);
g_option_context_set_summary (context, summary);
+ g_option_context_set_description (context, description);
g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
g_option_context_parse (context, &argc, &argv, &error);
g_option_context_free (context);
- g_free (summary);
+ g_free (param);
+ g_free (description);
if (error != NULL)
{
g_printerr (_("Error parsing commandline options: %s\n"), error->message);
g_printerr ("\n");
- g_printerr (_("Try \"%s --help\" for more information."),
- g_get_prgname ());
+ g_printerr (_("Try \"%s --help\" for more information."), g_get_prgname ());
g_printerr ("\n");
- g_error_free(error);
+ g_error_free (error);
return 1;
}
@@ -174,7 +172,7 @@ main (int argc, char *argv[])
g_printerr (_("%s: missing locations"), g_get_prgname ());
g_printerr ("\n");
g_printerr (_("Try \"%s --help\" for more information."),
- g_get_prgname ());
+ g_get_prgname ());
g_printerr ("\n");
return 1;
}
diff --git a/programs/gvfs-copy.c b/programs/gvfs-copy.c
index 9caf779a..9dce7c7f 100644
--- a/programs/gvfs-copy.c
+++ b/programs/gvfs-copy.c
@@ -41,12 +41,12 @@ static gboolean no_target_directory = FALSE;
static GOptionEntry entries[] =
{
- { "no-target-directory", 'T', 0, G_OPTION_ARG_NONE, &no_target_directory, N_("no target directory"), NULL },
- { "progress", 'p', 0, G_OPTION_ARG_NONE, &progress, N_("show progress"), NULL },
- { "interactive", 'i', 0, G_OPTION_ARG_NONE, &interactive, N_("prompt before overwrite"), NULL },
- { "preserve", 'p', 0, G_OPTION_ARG_NONE, &preserve, N_("preserve all attributes"), NULL },
- { "backup", 'b', 0, G_OPTION_ARG_NONE, &backup, N_("backup existing destination files"), NULL },
- { "no-dereference", 'P', 0, G_OPTION_ARG_NONE, &no_dereference, N_("never follow symbolic links"), NULL },
+ { "no-target-directory", 'T', 0, G_OPTION_ARG_NONE, &no_target_directory, N_("No target directory"), NULL },
+ { "progress", 'p', 0, G_OPTION_ARG_NONE, &progress, N_("Show progress"), NULL },
+ { "interactive", 'i', 0, G_OPTION_ARG_NONE, &interactive, N_("Prompt before overwrite"), NULL },
+ { "preserve", 'p', 0, G_OPTION_ARG_NONE, &preserve, N_("Preserve all attributes"), NULL },
+ { "backup", 'b', 0, G_OPTION_ARG_NONE, &backup, N_("Backup existing destination files"), NULL },
+ { "no-dereference", 'P', 0, G_OPTION_ARG_NONE, &no_dereference, N_("Never follow symbolic links"), NULL },
{ NULL }
};
@@ -106,13 +106,23 @@ main (int argc, char *argv[])
int i;
GFileCopyFlags flags;
int retval = 0;
+ char *param;
+ char *summary;
setlocale (LC_ALL, "");
+ bindtextdomain (GETTEXT_PACKAGE, GVFS_LOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ textdomain (GETTEXT_PACKAGE);
+
g_type_init ();
error = NULL;
- context = g_option_context_new (_("SOURCE... DEST - copy file(s) from SOURCE to DEST"));
+ param = g_strdup_printf ("%s... %s", _("SOURCE"), _("DEST"));
+ summary = _("Copy one or more files from SOURCE to DEST.");
+
+ context = g_option_context_new (param);
+ g_option_context_set_summary (context, summary);
g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
g_option_context_parse (context, &argc, &argv, &error);
@@ -120,10 +130,9 @@ main (int argc, char *argv[])
{
g_printerr (_("Error parsing commandline options: %s\n"), error->message);
g_printerr ("\n");
- g_printerr (_("Try \"%s --help\" for more information."),
- g_get_prgname ());
+ g_printerr (_("Try \"%s --help\" for more information."), g_get_prgname ());
g_printerr ("\n");
- g_error_free(error);
+ g_error_free (error);
return 1;
}
@@ -153,6 +162,7 @@ main (int argc, char *argv[])
}
g_option_context_free (context);
+ g_free (param);
for (i = 1; i < argc - 1; i++)
{
diff --git a/programs/gvfs-info.c b/programs/gvfs-info.c
index f9273c84..7808db22 100644
--- a/programs/gvfs-info.c
+++ b/programs/gvfs-info.c
@@ -36,8 +36,8 @@ static GOptionEntry entries[] =
{
{ "query-writable", 'w', 0, G_OPTION_ARG_NONE, &writable, N_("List writable attributes"), NULL },
{ "filesystem", 'f', 0, G_OPTION_ARG_NONE, &filesystem, N_("Get filesystem info"), NULL },
- { "attributes", 'a', 0, G_OPTION_ARG_STRING, &attributes, N_("The attributes to get"), NULL },
- { "nofollow-symlinks", 'n', 0, G_OPTION_ARG_NONE, &nofollow_symlinks, N_("Don't follow symlinks"), NULL },
+ { "attributes", 'a', 0, G_OPTION_ARG_STRING, &attributes, N_("The attributes to get"), N_("ATTRIBUTES") },
+ { "nofollow-symlinks", 'n', 0, G_OPTION_ARG_NONE, &nofollow_symlinks, N_("Don't follow symbolic links"), NULL },
{ NULL }
};
@@ -353,25 +353,35 @@ main (int argc, char *argv[])
GError *error;
GOptionContext *context;
GFile *file;
+ gchar *param;
+ gchar *summary;
setlocale (LC_ALL, "");
+ bindtextdomain (GETTEXT_PACKAGE, GVFS_LOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ textdomain (GETTEXT_PACKAGE);
+
g_type_init ();
error = NULL;
- context = g_option_context_new (_("- show info for <location>"));
+ param = g_strdup_printf ("[%s...]", _("LOCATION"));
+ summary = _("Show information about locations.");
+
+ context = g_option_context_new (param);
+ g_option_context_set_summary (context, summary);
g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
g_option_context_parse (context, &argc, &argv, &error);
g_option_context_free (context);
+ g_free (param);
if (error != NULL)
{
g_printerr (_("Error parsing commandline options: %s\n"), error->message);
g_printerr ("\n");
- g_printerr (_("Try \"%s --help\" for more information."),
- g_get_prgname ());
+ g_printerr (_("Try \"%s --help\" for more information."), g_get_prgname ());
g_printerr ("\n");
- g_error_free(error);
+ g_error_free (error);
return 1;
}
diff --git a/programs/gvfs-ls.c b/programs/gvfs-ls.c
index 13791f7c..45b3e680 100644
--- a/programs/gvfs-ls.c
+++ b/programs/gvfs-ls.c
@@ -36,11 +36,11 @@ static char *show_completions = NULL;
static GOptionEntry entries[] =
{
- { "attributes", 'a', 0, G_OPTION_ARG_STRING, &attributes, N_("The attributes to get"), NULL },
+ { "attributes", 'a', 0, G_OPTION_ARG_STRING, &attributes, N_("The attributes to get"), N_("ATTRIBUTES") },
{ "hidden", 'h', 0, G_OPTION_ARG_NONE, &show_hidden, N_("Show hidden files"), NULL },
{ "long", 'l', 0, G_OPTION_ARG_NONE, &show_long, N_("Use a long listing format"), NULL },
- { "show-completions", 'c', 0, G_OPTION_ARG_STRING, &show_completions, N_("Show completions"), NULL},
- { "nofollow-symlinks", 'n', 0, G_OPTION_ARG_NONE, &nofollow_symlinks, N_("Don't follow symlinks"), NULL},
+ { "show-completions", 'c', 0, G_OPTION_ARG_STRING, &show_completions, N_("Show completions"), N_("PREFIX") },
+ { "nofollow-symlinks", 'n', 0, G_OPTION_ARG_NONE, &nofollow_symlinks, N_("Don't follow symbolic links"), NULL},
{ NULL }
};
@@ -374,25 +374,41 @@ main (int argc, char *argv[])
GError *error;
GOptionContext *context;
GFile *file;
+ gchar *param;
+ gchar *summary;
+ gchar *description;
setlocale (LC_ALL, "");
+ bindtextdomain (GETTEXT_PACKAGE, GVFS_LOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ textdomain (GETTEXT_PACKAGE);
+
g_type_init ();
error = NULL;
- context = g_option_context_new (_("- list files at <location>"));
+ param = g_strdup_printf ("[%s...]", _("LOCATION"));
+ summary = _("List the contents of the locations.");
+ description = _("gvfs-ls is similar to the traditional ls utility, but using gvfs\n"
+ "locations instead of local files: for example you can use something\n"
+ "like smb://server/resource/file.txt as location. File attributes can\n"
+ "be specified with their gvfs name, e.g. standard::icon.");
+
+ context = g_option_context_new (param);
+ g_option_context_set_summary (context, summary);
+ g_option_context_set_description (context, description);
g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
g_option_context_parse (context, &argc, &argv, &error);
g_option_context_free (context);
+ g_free (param);
if (error != NULL)
{
g_printerr (_("Error parsing commandline options: %s\n"), error->message);
g_printerr ("\n");
- g_printerr (_("Try \"%s --help\" for more information."),
- g_get_prgname ());
+ g_printerr (_("Try \"%s --help\" for more information."), g_get_prgname ());
g_printerr ("\n");
- g_error_free(error);
+ g_error_free (error);
return 1;
}
diff --git a/programs/gvfs-mime.c b/programs/gvfs-mime.c
index 0930d615..99c4b9e9 100644
--- a/programs/gvfs-mime.c
+++ b/programs/gvfs-mime.c
@@ -67,44 +67,51 @@ main (int argc, char *argv[])
GError *error;
GOptionContext *context;
const char *mimetype;
+ gchar *param;
+ gchar *summary;
setlocale (LC_ALL, "");
+ bindtextdomain (GETTEXT_PACKAGE, GVFS_LOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ textdomain (GETTEXT_PACKAGE);
+
g_type_init ();
error = NULL;
- context = g_option_context_new (_("- get/set handler for <mimetype>"));
+ param = g_strdup_printf ("%s [%s]", _("MIMETYPE"), _("HANDLER"));
+ summary = _("Get or set the handler for a mime-type.");
+
+ context = g_option_context_new (param);
+ g_option_context_set_summary (context, summary);
g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
g_option_context_parse (context, &argc, &argv, &error);
g_option_context_free (context);
+ g_free (param);
- if (error != NULL ||
- query == set)
+ if (error != NULL || query == set)
{
g_printerr (_("Error parsing commandline options: %s\n"),
- error ? error->message : _("Specify one of --query and --set"));
+ error ? error->message : _("Specify either --query or --set"));
g_printerr ("\n");
- g_printerr (_("Try \"%s --help\" for more information."),
- g_get_prgname ());
+ g_printerr (_("Try \"%s --help\" for more information."), g_get_prgname ());
g_printerr ("\n");
if (error != NULL)
- g_error_free(error);
+ g_error_free (error);
return 1;
}
if (query && argc != 2)
{
g_printerr (_("Must specify a single mime-type.\n"));
- g_printerr (_("Try \"%s --help\" for more information."),
- g_get_prgname ());
+ g_printerr (_("Try \"%s --help\" for more information."), g_get_prgname ());
g_printerr ("\n");
return 1;
}
else if (set && argc != 3)
{
g_printerr (_("Must specify the mime-type followed by the default handler.\n"));
- g_printerr (_("Try \"%s --help\" for more information."),
- g_get_prgname ());
+ g_printerr (_("Try \"%s --help\" for more information."), g_get_prgname ());
g_printerr ("\n");
return 1;
}
diff --git a/programs/gvfs-mkdir.c b/programs/gvfs-mkdir.c
index 9c8ac2dc..77db4461 100644
--- a/programs/gvfs-mkdir.c
+++ b/programs/gvfs-mkdir.c
@@ -30,7 +30,7 @@
static gboolean parent = FALSE;
static GOptionEntry entries[] =
{
- { "parent", 'p', 0, G_OPTION_ARG_NONE, &parent, N_("create parent directories"), NULL },
+ { "parent", 'p', 0, G_OPTION_ARG_NONE, &parent, N_("Create parent directories"), NULL },
{ NULL }
};
@@ -42,25 +42,35 @@ main (int argc, char *argv[])
GOptionContext *context;
GFile *file;
int retval = 0;
+ gchar *param;
+ gchar *summary;
setlocale (LC_ALL, "");
+ bindtextdomain (GETTEXT_PACKAGE, GVFS_LOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ textdomain (GETTEXT_PACKAGE);
+
g_type_init ();
error = NULL;
- context = g_option_context_new (_("- create directories"));
+ param = g_strdup_printf ("[%s...]", _("LOCATION"));
+ summary = _("Create directories.");
+
+ context = g_option_context_new (param);
+ g_option_context_set_summary (context, summary);
g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
g_option_context_parse (context, &argc, &argv, &error);
g_option_context_free (context);
+ g_free (param);
if (error != NULL)
{
g_printerr (_("Error parsing commandline options: %s\n"), error->message);
g_printerr ("\n");
- g_printerr (_("Try \"%s --help\" for more information."),
- g_get_prgname ());
+ g_printerr (_("Try \"%s --help\" for more information."), g_get_prgname ());
g_printerr ("\n");
- g_error_free(error);
+ g_error_free (error);
return 1;
}
diff --git a/programs/gvfs-monitor-dir.c b/programs/gvfs-monitor-dir.c
index 45e8ffc3..3231d719 100644
--- a/programs/gvfs-monitor-dir.c
+++ b/programs/gvfs-monitor-dir.c
@@ -35,7 +35,7 @@ static GMainLoop *main_loop;
static gboolean dont_pair_moves = FALSE;
static GOptionEntry entries[] = {
- { "no-pair", 'N', 0, G_OPTION_ARG_NONE, &dont_pair_moves, N_("Don't send single MOVED events."), NULL },
+ { "no-pair", 'N', 0, G_OPTION_ARG_NONE, &dont_pair_moves, N_("Don't send single MOVED events"), NULL },
{ NULL }
};
@@ -97,16 +97,37 @@ main (int argc, char *argv[])
GError *error;
GOptionContext *context;
GFile *file;
+ gchar *param;
+ gchar *summary;
setlocale (LC_ALL, "");
+ bindtextdomain (GETTEXT_PACKAGE, GVFS_LOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ textdomain (GETTEXT_PACKAGE);
+
g_type_init ();
error = NULL;
- context = g_option_context_new ("- monitor directory <location> [location]...");
+ param = g_strdup_printf ("[%s...]", _("LOCATION"));
+ summary = _("Monitor directories for changes.");
+
+ context = g_option_context_new (param);
+ g_option_context_set_summary (context, summary);
g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
g_option_context_parse (context, &argc, &argv, &error);
g_option_context_free (context);
+ g_free (param);
+
+ if (error != NULL)
+ {
+ g_printerr (_("Error parsing commandline options: %s\n"), error->message);
+ g_printerr ("\n");
+ g_printerr (_("Try \"%s --help\" for more information."), g_get_prgname ());
+ g_printerr ("\n");
+ g_error_free (error);
+ return 1;
+ }
if (argc > 1)
{
diff --git a/programs/gvfs-monitor-file.c b/programs/gvfs-monitor-file.c
index 973b43df..ee19fb31 100644
--- a/programs/gvfs-monitor-file.c
+++ b/programs/gvfs-monitor-file.c
@@ -35,7 +35,7 @@ static GMainLoop *main_loop;
static gboolean dont_pair_moves = FALSE;
static GOptionEntry entries[] = {
- { "no-pair", 'N', 0, G_OPTION_ARG_NONE, &dont_pair_moves, N_("Don't send single MOVED events."), NULL },
+ { "no-pair", 'N', 0, G_OPTION_ARG_NONE, &dont_pair_moves, N_("Don't send single MOVED events"), NULL },
{ NULL }
};
@@ -96,16 +96,37 @@ main (int argc, char *argv[])
GError *error;
GOptionContext *context;
GFile *file;
+ gchar *param;
+ gchar *summary;
setlocale (LC_ALL, "");
+ bindtextdomain (GETTEXT_PACKAGE, GVFS_LOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ textdomain (GETTEXT_PACKAGE);
+
g_type_init ();
error = NULL;
- context = g_option_context_new ("- monitor file <location> [location]...");
+ param = g_strdup_printf ("[%s...]", _("LOCATION"));
+ summary = _("Monitor files for changes.");
+
+ context = g_option_context_new (param);
+ g_option_context_set_summary (context, summary);
g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
g_option_context_parse (context, &argc, &argv, &error);
g_option_context_free (context);
+ g_free (param);
+
+ if (error != NULL)
+ {
+ g_printerr (_("Error parsing commandline options: %s\n"), error->message);
+ g_printerr ("\n");
+ g_printerr (_("Try \"%s --help\" for more information."), g_get_prgname ());
+ g_printerr ("\n");
+ g_error_free (error);
+ return 1;
+ }
if (argc > 1)
{
diff --git a/programs/gvfs-mount.c b/programs/gvfs-mount.c
index c815294f..3530a95d 100644
--- a/programs/gvfs-mount.c
+++ b/programs/gvfs-mount.c
@@ -53,13 +53,13 @@ static const char *mount_device_file = NULL;
static const GOptionEntry entries[] =
{
{ "mountable", 'm', 0, G_OPTION_ARG_NONE, &mount_mountable, N_("Mount as mountable"), NULL },
- { "device", 'd', 0, G_OPTION_ARG_STRING, &mount_device_file, N_("Mount volume with device file"), NULL},
+ { "device", 'd', 0, G_OPTION_ARG_STRING, &mount_device_file, N_("Mount volume with device file"), N_("DEVICE") },
{ "unmount", 'u', 0, G_OPTION_ARG_NONE, &mount_unmount, N_("Unmount"), NULL},
{ "eject", 'e', 0, G_OPTION_ARG_NONE, &mount_eject, N_("Eject"), NULL},
- { "unmount-scheme", 's', 0, G_OPTION_ARG_STRING, &unmount_scheme, N_("Unmount all mounts with the given scheme"), NULL},
+ { "unmount-scheme", 's', 0, G_OPTION_ARG_STRING, &unmount_scheme, N_("Unmount all mounts with the given scheme"), N_("SCHEME") },
/* Translator: List here is a verb as in 'List all mounts' */
{ "list", 'l', 0, G_OPTION_ARG_NONE, &mount_list, N_("List"), NULL},
- { "detail", 'i', 0, G_OPTION_ARG_NONE, &extra_detail, N_("Show extra information for List and Monitor"), NULL},
+ { "detail", 'i', 0, G_OPTION_ARG_NONE, &extra_detail, N_("Show extra information"), NULL},
{ "monitor", 'o', 0, G_OPTION_ARG_NONE, &mount_monitor, N_("Monitor events"), NULL},
{ NULL }
};
@@ -201,7 +201,7 @@ new_mount_op (void)
g_signal_connect (op, "ask_password", G_CALLBACK (ask_password_cb), NULL);
- /* TODO: we *should* also connect to the "aborted" signal but since we the
+ /* TODO: we *should* also connect to the "aborted" signal but since the
* main thread is blocked handling input we won't get that signal
* anyway...
*/
@@ -990,16 +990,37 @@ main (int argc, char *argv[])
GOptionContext *context;
GError *error;
GFile *file;
+ gchar *param;
+ gchar *summary;
setlocale (LC_ALL, "");
+ bindtextdomain (GETTEXT_PACKAGE, GVFS_LOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ textdomain (GETTEXT_PACKAGE);
+
g_type_init ();
error = NULL;
- context = g_option_context_new (_("- mount <location>"));
+ param = g_strdup_printf ("[%s...]", _("LOCATION"));
+ summary = _("Mount the locations.");
+
+ context = g_option_context_new (param);
+ g_option_context_set_summary (context, summary);
g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
g_option_context_parse (context, &argc, &argv, &error);
g_option_context_free (context);
+ g_free (param);
+
+ if (error != NULL)
+ {
+ g_printerr (_("Error parsing commandline options: %s\n"), error->message);
+ g_printerr ("\n");
+ g_printerr (_("Try \"%s --help\" for more information."), g_get_prgname ());
+ g_printerr ("\n");
+ g_error_free (error);
+ return 1;
+ }
main_loop = g_main_loop_new (NULL, FALSE);
diff --git a/programs/gvfs-move.c b/programs/gvfs-move.c
index 97e92c66..301a954b 100644
--- a/programs/gvfs-move.c
+++ b/programs/gvfs-move.c
@@ -39,10 +39,10 @@ static gboolean no_target_directory = FALSE;
static GOptionEntry entries[] =
{
- { "no-target-directory", 'T', 0, G_OPTION_ARG_NONE, &no_target_directory, N_("no target directory"), NULL },
- { "progress", 'p', 0, G_OPTION_ARG_NONE, &progress, N_("show progress"), NULL },
- { "interactive", 'i', 0, G_OPTION_ARG_NONE, &interactive, N_("prompt before overwrite"), NULL },
- { "backup", 'b', 0, G_OPTION_ARG_NONE, &backup, N_("backup existing destination files"), NULL },
+ { "no-target-directory", 'T', 0, G_OPTION_ARG_NONE, &no_target_directory, N_("No target directory"), NULL },
+ { "progress", 'p', 0, G_OPTION_ARG_NONE, &progress, N_("Show progress"), NULL },
+ { "interactive", 'i', 0, G_OPTION_ARG_NONE, &interactive, N_("Prompt before overwrite"), NULL },
+ { "backup", 'b', 0, G_OPTION_ARG_NONE, &backup, N_("Backup existing destination files"), NULL },
{ NULL }
};
@@ -94,13 +94,23 @@ main (int argc, char *argv[])
int i;
GFileCopyFlags flags;
int retval = 0;
+ gchar *param;
+ gchar *summary;
setlocale (LC_ALL, "");
+ bindtextdomain (GETTEXT_PACKAGE, GVFS_LOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ textdomain (GETTEXT_PACKAGE);
+
g_type_init ();
error = NULL;
- context = g_option_context_new (_("SOURCE... DEST - move file(s) from SOURCE to DEST"));
+ param = g_strdup_printf ("%s... %s", _("SOURCE"), _("DEST"));
+ summary = _("Move one or more files from SOURCE to DEST.");
+
+ context = g_option_context_new (param);
+ g_option_context_set_summary (context, summary);
g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
g_option_context_parse (context, &argc, &argv, &error);
@@ -108,10 +118,9 @@ main (int argc, char *argv[])
{
g_printerr (_("Error parsing commandline options: %s\n"), error->message);
g_printerr ("\n");
- g_printerr (_("Try \"%s --help\" for more information."),
- g_get_prgname ());
+ g_printerr (_("Try \"%s --help\" for more information."), g_get_prgname ());
g_printerr ("\n");
- g_error_free(error);
+ g_error_free (error);
return 1;
}
@@ -141,6 +150,7 @@ main (int argc, char *argv[])
}
g_option_context_free (context);
+ g_free (param);
for (i = 1; i < argc - 1; i++)
{
diff --git a/programs/gvfs-open.c b/programs/gvfs-open.c
index 6836a14a..ded6cad2 100644
--- a/programs/gvfs-open.c
+++ b/programs/gvfs-open.c
@@ -34,7 +34,7 @@
static gchar **locations = NULL;
static GOptionEntry entries[] = {
- {G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &locations, N_("files"), NULL},
+ {G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &locations, NULL, NULL },
{NULL}
};
@@ -43,6 +43,7 @@ main (int argc, char *argv[])
{
GError *error = NULL;
GOptionContext *context = NULL;
+ gchar *param;
gchar *summary;
int i;
gboolean success;
@@ -57,31 +58,26 @@ main (int argc, char *argv[])
g_type_init ();
- /* Translators: this message will appear immediately after the */
- /* usage string - Usage: COMMAND [OPTION]... <THIS_MESSAGE> */
- context =
- g_option_context_new (_("FILES... - open FILES with registered application."));
-
+ param = g_strdup_printf ("%s...", _("FILE"));
/* Translators: this message will appear after the usage string */
/* and before the list of options. */
- summary = _("Opens the file(s) with the default application "
- "registered to handle the type of the file.");
+ summary = _("Open files with the default application that\n"
+ "is registered to handle files of this type.");
+ context = g_option_context_new (param);
g_option_context_set_summary (context, summary);
-
g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
g_option_context_parse (context, &argc, &argv, &error);
-
g_option_context_free (context);
+ g_free (param);
if (error != NULL)
{
g_printerr (_("Error parsing commandline options: %s\n"), error->message);
g_printerr ("\n");
- g_printerr (_("Try \"%s --help\" for more information."),
- g_get_prgname ());
+ g_printerr (_("Try \"%s --help\" for more information."), g_get_prgname ());
g_printerr ("\n");
- g_error_free(error);
+ g_error_free (error);
return 1;
}
diff --git a/programs/gvfs-rename.c b/programs/gvfs-rename.c
index 51cdb586..4b4ecb82 100644
--- a/programs/gvfs-rename.c
+++ b/programs/gvfs-rename.c
@@ -27,11 +27,19 @@
#include <glib/gi18n.h>
#include <gio/gio.h>
-static GOptionEntry entries[] =
+static void
+show_help (GOptionContext *context, const char *error)
{
- { NULL }
-};
+ 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[])
@@ -41,24 +49,44 @@ main (int argc, char *argv[])
GFile *file;
GFile *new_file;
int retval = 0;
+ gchar *param;
+ gchar *summary;
setlocale (LC_ALL, "");
+ bindtextdomain (GETTEXT_PACKAGE, GVFS_LOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ textdomain (GETTEXT_PACKAGE);
+
g_type_init ();
error = NULL;
- context = g_option_context_new (_("- rename file"));
- g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
+ param = g_strdup_printf ("%s %s", _("LOCATION"), _("NEW-NAME"));
+ summary = _("Rename a file.");
+
+ context = g_option_context_new (param);
+ g_option_context_set_summary (context, summary);
g_option_context_parse (context, &argc, &argv, &error);
- g_option_context_free (context);
+
+ if (error != NULL)
+ {
+ g_printerr (_("Error parsing commandline options: %s\n"), error->message);
+ g_printerr ("\n");
+ g_printerr (_("Try \"%s --help\" for more information."), g_get_prgname ());
+ g_printerr ("\n");
+ g_error_free (error);
+ return 1;
+ }
if (argc < 3)
{
- g_printerr ("Usage: %s location new_name\n",
- g_get_prgname ());
+ show_help (context, _("Missing operand\n"));
return 1;
}
+ g_option_context_free (context);
+ g_free (param);
+
file = g_file_new_for_commandline_arg (argv[1]);
new_file = g_file_set_display_name (file, argv[2],
diff --git a/programs/gvfs-rm.c b/programs/gvfs-rm.c
index 52af8ccf..bad1c78f 100644
--- a/programs/gvfs-rm.c
+++ b/programs/gvfs-rm.c
@@ -31,8 +31,7 @@ static gboolean force = FALSE;
static GOptionEntry entries[] =
{
- {"force", 'f', 0, G_OPTION_ARG_NONE, &force,
- N_("ignore nonexistent files, never prompt"), NULL},
+ {"force", 'f', 0, G_OPTION_ARG_NONE, &force, N_("Ignore nonexistent files, never prompt"), NULL},
{ NULL }
};
@@ -44,16 +43,37 @@ main (int argc, char *argv[])
GOptionContext *context;
GFile *file;
int retval = 0;
+ gchar *param;
+ gchar *summary;
setlocale (LC_ALL, "");
+ bindtextdomain (GETTEXT_PACKAGE, GVFS_LOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ textdomain (GETTEXT_PACKAGE);
+
g_type_init ();
error = NULL;
- context = g_option_context_new (_("- delete files"));
+ param = g_strdup_printf ("[%s...]", _("FILE"));
+ summary = _("Delete the given files.");
+
+ context = g_option_context_new (param);
+ g_option_context_set_summary (context, summary);
g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
g_option_context_parse (context, &argc, &argv, &error);
g_option_context_free (context);
+ g_free (param);
+
+ if (error != NULL)
+ {
+ g_printerr (_("Error parsing commandline options: %s\n"), error->message);
+ g_printerr ("\n");
+ g_printerr (_("Try \"%s --help\" for more information."), g_get_prgname ());
+ g_printerr ("\n");
+ g_error_free (error);
+ return 1;
+ }
if (argc > 1)
{
diff --git a/programs/gvfs-save.c b/programs/gvfs-save.c
index e9426c68..bc7ed9b5 100644
--- a/programs/gvfs-save.c
+++ b/programs/gvfs-save.c
@@ -40,12 +40,12 @@ static gboolean print_etag = FALSE;
static GOptionEntry entries[] =
{
- { "backup", 'b', 0, G_OPTION_ARG_NONE, &backup, N_("Create backup"), NULL },
+ { "backup", 'b', 0, G_OPTION_ARG_NONE, &backup, N_("Backup existing destination files"), NULL },
{ "create", 'c', 0, G_OPTION_ARG_NONE, &create, N_("Only create if not existing"), NULL },
{ "append", 'a', 0, G_OPTION_ARG_NONE, &append, N_("Append to end of file"), NULL },
- { "private", 'p', 0, G_OPTION_ARG_NONE, &priv, N_("When creating a file, restrict access to the current user only"), NULL },
+ { "private", 'p', 0, G_OPTION_ARG_NONE, &priv, N_("When creating, restrict access to the current user"), NULL },
{ "print_etag", 'v', 0, G_OPTION_ARG_NONE, &print_etag, N_("Print new etag at end"), NULL },
- { "etag", 'e', 0, G_OPTION_ARG_STRING, &etag, N_("The etag of the file being overwritten"), NULL },
+ { "etag", 'e', 0, G_OPTION_ARG_STRING, &etag, N_("The etag of the file being overwritten"), N_("ETAG") },
{ NULL }
};
@@ -68,9 +68,9 @@ save (GFile *file)
if (create)
out = (GOutputStream *)g_file_create (file, flags, NULL, &error);
else if (append)
- out = (GOutputStream *)g_file_append_to (file, flags, NULL, &error);
+ out = (GOutputStream *)g_file_append_to (file, flags, NULL, &error);
else
- out = (GOutputStream *)g_file_replace (file, etag, backup, flags, NULL, &error);
+ out = (GOutputStream *)g_file_replace (file, etag, backup, flags, NULL, &error);
if (out == NULL)
{
g_printerr (_("Error opening file: %s\n"), error->message);
@@ -147,13 +147,23 @@ main (int argc, char *argv[])
GOptionContext *context;
GFile *file;
gboolean res;
+ gchar *param;
+ gchar *summary;
setlocale (LC_ALL, "");
+ bindtextdomain (GETTEXT_PACKAGE, GVFS_LOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ textdomain (GETTEXT_PACKAGE);
+
g_type_init ();
error = NULL;
- context = g_option_context_new (_("DEST - read from standard input and save to DEST"));
+ param = _("DEST");
+ summary = _("Read from standard input and save to DEST.");
+
+ context = g_option_context_new (param);
+ g_option_context_set_summary (context, summary);
g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
g_option_context_parse (context, &argc, &argv, &error);
g_option_context_free (context);
@@ -162,10 +172,9 @@ main (int argc, char *argv[])
{
g_printerr (_("Error parsing commandline options: %s\n"), error->message);
g_printerr ("\n");
- g_printerr (_("Try \"%s --help\" for more information."),
- g_get_prgname ());
+ g_printerr (_("Try \"%s --help\" for more information."), g_get_prgname ());
g_printerr ("\n");
- g_error_free(error);
+ g_error_free (error);
return 1;
}
diff --git a/programs/gvfs-set-attribute.c b/programs/gvfs-set-attribute.c
index 931841ec..2653d893 100644
--- a/programs/gvfs-set-attribute.c
+++ b/programs/gvfs-set-attribute.c
@@ -33,8 +33,8 @@ static gboolean nofollow_symlinks = FALSE;
static GOptionEntry entries[] =
{
- { "type", 't', 0, G_OPTION_ARG_STRING, &attr_type, N_("attribute type [string, bytestring, boolean, uint32, int32, uint64, int64, stringv, unset]"), NULL },
- { "nofollow-symlinks", 'n', 0, G_OPTION_ARG_NONE, &nofollow_symlinks, N_("Don't follow symlinks"), NULL },
+ { "type", 't', 0, G_OPTION_ARG_STRING, &attr_type, N_("Type of the attribute"), N_("TYPE") },
+ { "nofollow-symlinks", 'n', 0, G_OPTION_ARG_NONE, &nofollow_symlinks, N_("Don't follow symbolic links"), NULL },
{ NULL }
};
@@ -96,6 +96,20 @@ attribute_type_from_string (const char *str)
return -1;
}
+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[])
{
@@ -110,31 +124,39 @@ main (int argc, char *argv[])
gint32 int32;
guint64 uint64;
gint64 int64;
+ gchar *param;
+ gchar *summary;
setlocale (LC_ALL, "");
+ bindtextdomain (GETTEXT_PACKAGE, GVFS_LOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ textdomain (GETTEXT_PACKAGE);
+
g_type_init ();
error = NULL;
- context = g_option_context_new (_(" <location> <attribute> <values> - set attribute"));
+ param = g_strdup_printf ("%s %s %s...", _("LOCATION"), _("ATTRIBUTE"), _("VALUE"));
+ summary = _("Set a file attribute of LOCATION.");
+
+ context = g_option_context_new (param);
+ g_option_context_set_summary (context, summary);
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)
{
g_printerr (_("Error parsing commandline options: %s\n"), error->message);
g_printerr ("\n");
- g_printerr (_("Try \"%s --help\" for more information."),
- g_get_prgname ());
+ g_printerr (_("Try \"%s --help\" for more information."), g_get_prgname ());
g_printerr ("\n");
- g_error_free(error);
+ g_error_free (error);
return 1;
}
if (argc < 2)
{
- g_printerr (_("Location not specified\n"));
+ show_help (context, _("Location not specified\n"));
return 1;
}
@@ -142,7 +164,7 @@ main (int argc, char *argv[])
if (argc < 3)
{
- g_printerr (_("Attribute not specified\n"));
+ show_help (context, _("Attribute not specified\n"));
return 1;
}
@@ -151,10 +173,13 @@ main (int argc, char *argv[])
type = attribute_type_from_string (attr_type);
if ((argc < 4) && (type != G_FILE_ATTRIBUTE_TYPE_INVALID))
{
- g_printerr (_("Value not specified\n"));
+ show_help (context, _("Value not specified\n"));
return 1;
}
+ g_option_context_free (context);
+ g_free (param);
+
switch (type)
{
case G_FILE_ATTRIBUTE_TYPE_STRING:
diff --git a/programs/gvfs-trash.c b/programs/gvfs-trash.c
index e745319e..3a601167 100644
--- a/programs/gvfs-trash.c
+++ b/programs/gvfs-trash.c
@@ -31,8 +31,7 @@ static gboolean force = FALSE;
static GOptionEntry entries[] =
{
- {"force", 'f', 0, G_OPTION_ARG_NONE, &force,
- N_("ignore nonexistent files, never prompt"), NULL},
+ {"force", 'f', 0, G_OPTION_ARG_NONE, &force, N_("Ignore nonexistent files, never prompt"), NULL},
{ NULL }
};
@@ -43,16 +42,37 @@ main (int argc, char *argv[])
GOptionContext *context;
GFile *file;
int retval = 0;
+ gchar *param;
+ gchar *summary;
setlocale (LC_ALL, "");
+ bindtextdomain (GETTEXT_PACKAGE, GVFS_LOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ textdomain (GETTEXT_PACKAGE);
+
g_type_init ();
error = NULL;
- context = g_option_context_new (_("- move files to trash"));
+ param = g_strdup_printf ("[%s...]", _("FILE"));
+ summary = _("Move files to the trash.");
+
+ context = g_option_context_new (param);
+ g_option_context_set_summary (context, summary);
g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
g_option_context_parse (context, &argc, &argv, &error);
g_option_context_free (context);
+ g_free (param);
+
+ if (error != NULL)
+ {
+ g_printerr (_("Error parsing commandline options: %s\n"), error->message);
+ g_printerr ("\n");
+ g_printerr (_("Try \"%s --help\" for more information."), g_get_prgname ());
+ g_printerr ("\n");
+ g_error_free (error);
+ return 1;
+ }
if (argc > 1)
{
diff --git a/programs/gvfs-tree.c b/programs/gvfs-tree.c
index f235df59..fc678846 100644
--- a/programs/gvfs-tree.c
+++ b/programs/gvfs-tree.c
@@ -34,7 +34,7 @@ static gboolean follow_symlinks = FALSE;
static GOptionEntry entries[] =
{
{ "hidden", 'h', 0, G_OPTION_ARG_NONE, &show_hidden, N_("Show hidden files"), NULL },
- { "follow-symlinks", 'l', 0, G_OPTION_ARG_NONE, &follow_symlinks, N_("Follow symbolic links, mounts and shortcuts like directories"), NULL },
+ { "follow-symlinks", 'l', 0, G_OPTION_ARG_NONE, &follow_symlinks, N_("Follow symbolic links, mounts and shortcuts"), NULL },
};
static gint
@@ -233,25 +233,35 @@ main (int argc, char *argv[])
GError *error;
GOptionContext *context;
GFile *file;
+ gchar *param;
+ gchar *summary;
setlocale (LC_ALL, "");
+ bindtextdomain (GETTEXT_PACKAGE, GVFS_LOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ textdomain (GETTEXT_PACKAGE);
+
g_type_init ();
error = NULL;
- context = g_option_context_new (_("- list contents of directories in a tree-like format"));
+ param = g_strdup_printf ("[%s...]", _("LOCATION"));
+ summary = _("List contents of directories in a tree-like format.");
+
+ context = g_option_context_new (param);
+ g_option_context_set_summary (context, summary);
g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
g_option_context_parse (context, &argc, &argv, &error);
g_option_context_free (context);
+ g_free (param);
if (error != NULL)
{
g_printerr (_("Error parsing commandline options: %s\n"), error->message);
g_printerr ("\n");
- g_printerr (_("Try \"%s --help\" for more information."),
- g_get_prgname ());
+ g_printerr (_("Try \"%s --help\" for more information."), g_get_prgname ());
g_printerr ("\n");
- g_error_free(error);
+ g_error_free (error);
return 1;
}