summaryrefslogtreecommitdiffstats
path: root/tools/gpg-wks-client.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2024-02-21 14:06:37 +0100
committerWerner Koch <wk@gnupg.org>2024-02-21 14:07:06 +0100
commita09157ccb2bdd9b9197e64eb9d60953c1d5c46ae (patch)
treef81fa986d3bd20af4ec7c09ef1cf7417ad0a07c9 /tools/gpg-wks-client.c
parentg13: Allow command line style "g13 mount foo". (diff)
downloadgnupg2-a09157ccb2bdd9b9197e64eb9d60953c1d5c46ae.tar.xz
gnupg2-a09157ccb2bdd9b9197e64eb9d60953c1d5c46ae.zip
wks: Allow command style args for gpg-wks-client.
* tools/gpg-wks-client.c (wrong_args): Take two args. Change all callers. (main): Pass ARGPARSE_FLAG_COMMAND for recent gpgrt version. -- This requires gpgrt 1.48. Of course "gpg-wks-client --create ..." continues to work.
Diffstat (limited to '')
-rw-r--r--tools/gpg-wks-client.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/tools/gpg-wks-client.c b/tools/gpg-wks-client.c
index fa0278ae0..edb31f38b 100644
--- a/tools/gpg-wks-client.c
+++ b/tools/gpg-wks-client.c
@@ -154,7 +154,7 @@ static char **blacklist_array;
static size_t blacklist_array_len;
-static void wrong_args (const char *text) GPGRT_ATTR_NORETURN;
+static void wrong_args (const char *t1, const char *t2) GPGRT_ATTR_NORETURN;
static void add_blacklist (const char *fname);
static gpg_error_t proc_userid_from_stdin (gpg_error_t (*func)(const char *),
const char *text);
@@ -204,10 +204,15 @@ my_strusage( int level )
static void
-wrong_args (const char *text)
+wrong_args (const char *text, const char *text2)
{
- es_fprintf (es_stderr, _("usage: %s [options] %s\n"),
- gpgrt_strusage (11), text);
+#if GPGRT_VERSION_NUMBER >= 0x013000 /* >= 1.48 */
+ /* Skip the leading dashes if build with command support. */
+ if (text[0] == '-' && text[1] == '-' && text[2])
+ text += 2;
+#endif
+ es_fprintf (es_stderr, _("usage: %s %s [options] %s\n"),
+ gpgrt_strusage (11), text, text2);
exit (2);
}
@@ -315,6 +320,9 @@ main (int argc, char **argv)
pargs.argc = &argc;
pargs.argv = &argv;
pargs.flags = ARGPARSE_FLAG_KEEP;
+#if GPGRT_VERSION_NUMBER >= 0x013000 /* >= 1.48 */
+ pargs.flags |= ARGPARSE_FLAG_COMMAND;
+#endif
cmd = parse_arguments (&pargs, opts);
gpgrt_argparse (NULL, &pargs, NULL);
@@ -394,7 +402,7 @@ main (int argc, char **argv)
else
{
if (argc != 1)
- wrong_args ("--supported DOMAIN");
+ wrong_args ("--supported", "DOMAIN");
err = command_supported (argv[0]);
if (err && gpg_err_code (err) != GPG_ERR_FALSE)
log_error ("checking support failed: %s\n", gpg_strerror (err));
@@ -403,7 +411,7 @@ main (int argc, char **argv)
case aCreate:
if (argc != 2)
- wrong_args ("--create FINGERPRINT USER-ID");
+ wrong_args ("--create", "FINGERPRINT USER-ID");
err = command_create (argv[0], argv[1]);
if (err)
log_error ("creating request failed: %s\n", gpg_strerror (err));
@@ -411,7 +419,7 @@ main (int argc, char **argv)
case aReceive:
if (argc)
- wrong_args ("--receive < MIME-DATA");
+ wrong_args ("--receive", "< MIME-DATA");
err = wks_receive (es_stdin, command_receive_cb, NULL);
if (err)
log_error ("processing mail failed: %s\n", gpg_strerror (err));
@@ -419,7 +427,7 @@ main (int argc, char **argv)
case aRead:
if (argc)
- wrong_args ("--read < WKS-DATA");
+ wrong_args ("--read", "< WKS-DATA");
err = read_confirmation_request (es_stdin);
if (err)
log_error ("processing mail failed: %s\n", gpg_strerror (err));
@@ -427,7 +435,7 @@ main (int argc, char **argv)
case aCheck:
if (argc != 1)
- wrong_args ("--check USER-ID");
+ wrong_args ("--check", "USER-ID");
err = command_check (argv[0]);
break;
@@ -444,12 +452,12 @@ main (int argc, char **argv)
else if (argc == 2)
err = wks_cmd_install_key (*argv, argv[1]);
else
- wrong_args ("--install-key [FILE|FINGERPRINT USER-ID]");
+ wrong_args ("--install-key", "[FILE|FINGERPRINT USER-ID]");
break;
case aRemoveKey:
if (argc != 1)
- wrong_args ("--remove-key USER-ID");
+ wrong_args ("--remove-key", "USER-ID");
err = wks_cmd_remove_key (*argv);
break;