Hi GNUnet folks! I have edited the gnunet-search utility to accept a --format and a --dir-format parameters and produce a printf-like output. It was pretty easy to do, I only had to edit gnunet/src/fs/gnunet-search.c <https://git.gnunet.org/gnunet.git/tree/src/fs/gnunet-search.c?id=65f9e37ce036acdfab29b25b9b6f69de1b126962>. The new text printed by gnunet-search --help can explain the two new arguments in detail:
$ gnunet-search --help
gnunet-search [OPTIONS] KEYWORD
Search GNUnet for files that were 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-format=DIRFORMAT write search results for directories according to
DIRFORMAT, where %n is the result number, %f is
the file's name and %u is the file's URI; if
missing defaults to FORMAT; if the latter is
missing too defaults to '#%n:\ngnunet-download
-o "%f" -R %u\n\n'
-f, --format=FORMAT write search results according to FORMAT, where
%n is the result number, %f is the file's name
and %u is the file's URI; if missing defaults
to '#%n:\ngnunet-download -o "%f" %u\n\n')
-h, --help print this help
-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=PREFIX write search results to file starting with PREFIX
-t, --timeout=DELAY automatically terminate search after DELAY
-V, --verbose be verbose
-v, --version print the version number
Report bugs to [email protected].
Home page: http://www.gnu.org/s/gnunet/
General help using GNU software: http://www.gnu.org/gethelp/
Basically with this new patch launching
gnunet-search commons
and launching
gnunet-search --format='#%n:\ngnunet-download -o "%f" %u\n\n' \
--dir-format='#%n:\ngnunet-download -o "%f" -R %u\n\n' \
commons
are equivalent.
What do you think? I hope you like the idea.
I have done my best to stick to the coding style of the rest of the
program. But a good code review is more than welcomed.
Please find attached a patch, or alternatively the single file I have
edited.
--madmurphy
<<attachment: gnunet-search_updated.zip>>
<<attachment: add_format_paramenter_to_gnunet-search.patch.zip>>
