From c827d5eefc314ae022a79ca79c2029ab0fe5b898 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 9 May 2019 18:58:06 +0200 Subject: [PATCH] add -q option to restrict output to just the public key --- doc/man/gnunet-identity.1 | 2 ++ src/identity/gnunet-identity.c | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/doc/man/gnunet-identity.1 b/doc/man/gnunet-identity.1 index 4a8970cf5..e51bbc85d 100644 --- a/doc/man/gnunet-identity.1 +++ b/doc/man/gnunet-identity.1 @@ -63,6 +63,8 @@ Perform "set" operation with the respective ego or restrict "display" operation Print the help page. .It d | \-display Display all of our egos. +.It q | \-quiet +Be quiet, in particular outputs only the public key when listing egos. .It v | \-verbose Be verbose, in particular outputs the public key of freshly created egos. .It m | \-monitor diff --git a/src/identity/gnunet-identity.c b/src/identity/gnunet-identity.c index 8366b9918..635c59efd 100644 --- a/src/identity/gnunet-identity.c +++ b/src/identity/gnunet-identity.c @@ -55,6 +55,11 @@ static int monitor; */ static unsigned int verbose; +/** + * Was "quiet" specified? + */ +static int quiet; + /** * -C option */ @@ -293,7 +298,12 @@ print_ego (void *cls, GNUNET_IDENTITY_ego_get_public_key (ego, &pk); s = GNUNET_CRYPTO_ecdsa_public_key_to_string (&pk); if ((monitor) || (NULL != identifier)) - fprintf (stdout, "%s - %s\n", identifier, s); + { + if (quiet) + fprintf (stdout, "%s\n", s); + else + fprintf (stdout, "%s - %s\n", identifier, s); + } GNUNET_free (s); } @@ -354,6 +364,10 @@ main (int argc, char *const *argv) "display", gettext_noop ("display all egos"), &list), + GNUNET_GETOPT_option_flag ('q', + "quiet", + gettext_noop ("reduce output"), + &quiet), GNUNET_GETOPT_option_string ( 'e', "ego", -- 2.25.1