|Subject:||Re: printf-like output for gnunet-search|
|Date:||Mon, 7 Feb 2022 12:47:51 +0000|
Thank you a lot, Carlo.
--dir-format) was the original name. Then I saw that the tendency favoured
--dir-printf) more and I changed it – but I have intentionally left
-F) for the short name(s). The new name is actually inspired to the
-printf argument of
%f have even identical meaning in both
gnunet-search), but if you guys think that
--dir-format) is better, then I will change it back.
In the meanwhile, silly me, I had forgotten to actually implement the
%s specifier for the file size. I did that now (patch attached). I also added a
argument for when people only want to create a GNUnet directory and
don't care about the output printed on screen. And finally, I tried to
expand the help page a bit. Here is the new text:
$ gnunet-search --help gnunet-search [OPTIONS] KEYWORD Search for files that have been published on GNUnet Arguments mandatory for long options are also mandatory for short options. -a, --anonymity=LEVEL set the desired LEVEL of receiver-anonymity -c, --config=FILENAME use configuration file FILENAME -F, --dir-printf=FORMAT write search results for directories according to FORMAT, where %a is the complete list of all the printable metadata available (each member of which will be displayed according to the --prop-printf argument), %f is the directory's name, %l is the directory name's length, %m is the directory's mime type (always equal to `application/gnunet-directory`), %n is the search result number, %s is the directory's size in bytes and %u is the directory's URI; if missing, --dir-printf defaults to the --printf argument; if the latter is missing too --dir-printf defaults to `#%n:\ngnunet-download -o "%f" -R %u\n\n` -f, --printf=FORMAT write search results according to FORMAT, where %a is the complete list of all the printable metadata available (each member of which will be displayed according to the --prop-printf argument), %f is the file's name, %l is the file name's length, %m is the file's mime type, %n is the search result number, %s is the file's size in bytes and %u is the file's URI; if missing, --printf defaults to `#%n:\ngnunet-download -o "%f" %u\n\n` -h, --help print this help -i, --prop-printf=FORMAT when the %a format specifier appears in --printf or --dir-printf, list each metadata property according to FORMAT, where %p is the property's content, %l is the content's length in bytes, %t is the property type, %i is the property type's unique identifier, %n is the property number and %w is the name of the plugin that provided the information; if missing, --prop-printf defaults to `\t%t: %p\n` -L, --log=LOGLEVEL configure logging to use LOGLEVEL -l, --logfile=FILENAME configure logging to write logs to FILENAME -N, --results=VALUE automatically terminate search after VALUE results are found -n, --no-network only search the local peer (no P2P network search) -o, --output=FILENAME create a GNUnet directory with search results at FILENAME (e.g. `gnunet-search --output=commons.gnd commons`) -s, --silent silent mode (requires the --output argument) -t, --timeout=DELAY automatically terminate search after DELAY (in number of microseconds); if 0 or omitted il means to wait for CTRL-C -V, --verbose be verbose -v, --version print the version number Report bugs to email@example.com. Home page: http://www.gnu.org/s/gnunet/ General help using GNU software: http://www.gnu.org/gethelp/
Despite the multiple possibilities that the new features offer, I think the most needed one was the simplest one: that of simply launching
gnunet-search -f '%f\n' commons
and print a simple naked list of the files that can be retrieved with the
commons keyword, without any URI or distractions (if later I want to actually download something I will omit the
--printf argument, or use another format that contains the
%u specifier). But the possibilities are really many.
There is still room for additions, but there is also no hurry.
Thank you, madmurphy! I think several of the gnunet
CLI tools need improvements of this kind, actually.
I vaguely remember doing similar edits somewhere -
making outputs friendly to parse.
On Sat, Feb 05, 2022 at 08:09:02AM +0000, madmurphy wrote:
> 1. What do you think about the fact that I have named the new arguments
> --printf, --dir-printf and --prop-printf? Do you think that alternative
> names would be better?
Since %u %n etc now have a very different meaning from
what they mean in regular printf, I would rather just
call them --format, --dir-format and --prop-format.
> 5. Do you like the idea?
> > -F, --dir-format=DIRFORMAT write search results for directories according to
> > -f, --format=FORMAT write search results according to FORMAT, where
Oh, you already had it that way.
Description: Zip archive
|[Prev in Thread]||Current Thread||[Next in Thread]|