|
From: | madmurphy |
Subject: | Re: printf-like output for gnunet-search |
Date: | Fri, 11 Feb 2022 21:05:10 +0000 |
Hi Alessio,
Thank you for the feedback.
I think the help text when using `--help' is too long. That's not really the place to write the _full_ explanation of the option; that's the man page's job.
Instinctively I would say that the help page
grew because I was not updating the man page while I was adding features
to the program, and if I did not document them immediately somewhere
I would forget what I added, so I documented them in the help page. But
now that there is an updated man page we can re-think the help page a
bit.
This is the current output (I already started to strike things out):
$ gnunet-search --help gnunet-search [OPTIONS] KEYWORD1 KEYWORD2 ... Search for files that have been published on GNUnetKeywords should start with a plus sign to indicate that they are required - e.g. `gnunet-search commons gpl` searches for files that match *either* "commons" or "gpl", whereas `gnunet-search +commons +gpl` searches for files that match *both* "commons" and "gpl".Arguments mandatory for long options are also mandatory for short options. -a, --anonymity=LEVEL set the desired LEVEL of receiver-anonymity (default: 1) -b, --bookmark-only do not search, print only the URI that points to this search -c, --config=FILENAME use configuration file FILENAME -F, --dir-printf=FORMAT write search results for directories according to FORMAT; the format specifiers supported here are identical to those supported in the --printf argument (please refer to it for more information); if missing, --dir-printf defaults to --printf; if --printf 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 will be displayed according to the --iter-printf argument) - use %j for printing only one field - %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; the %a and %j specifiers optionally support metatype filtering via hash sign (e.g. `%5#j` prints a book title, if present - see libextractor's metatypes for the complete list of numerical identifiers); if missing, --printf defaults to `#%n:\ngnunet-download -o "%f" %u\n\n` -h, --help print this help -i, --iter-printf=FORMAT when the %a or %j format specifiers appear 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, --iter-printf defaults to ` %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; the value given must be a number followed by a space and a time unit, for example "500 ms"; without a unit it defaults to microseconds - 1000000 = 1 second; if 0 or omitted it means to wait for CTRL-C -V, --verbose be verbose (append "%a\n" to the default --printf and --dir-printf arguments - ignored when these are provided by the user) -v, --version print the version number Report bugs to gnunet-developers@gnu.org. Home page: http://www.gnu.org/s/gnunet/ General help using GNU software: http://www.gnu.org/gethelp/
Point by point…
Even the tool's description should be reverted to the simpler one-liner that was used previously.
The main reason is that it's so long to be basically unreadable.
Okay, I can do that (I already striked out the addition in the tool's description).
As an example, the help string for `--printf', which other than being about four sentences long also contains a list of items, should probably be reworded like so:
"Write search results according to FORMAT. See the documentation for the available placeholders."
Then you can add a dedicated section in the man page titled "Formatting the output" or something like that.
Here
I am not sure if a description of the format specifiers can be
completely absent in the help page. Man pages are not always installed
by people, and a help page should be able to explain the bare minimum.
What do other people think about removing all mentions of the %
format specifiers from the help page?
`--dir-printf' should use the same string, instead of referencing some other option. It is generally a good idea to treat each help message as an independent entity — at least personally speaking, oftentimes I find myself scanning the left column for a specific optiong and only after I find it I read the help text, so having to navigate back and forth because the option I need just says "alias for foo" ends up being rather annoying in the long run.
If we do mention the format specifiers in the help page, then the text of --dir-printf
does become too long, and the best is that it refers to --printf
like it does now. But if we remove the format specifiers from the help
page, then yes, it can be its own text. However, since when not
specified --dir-printf
defaults to --printf
, a mention of --printf
will always be there in a way or another.
Maybe we can amend the output of gnunet-search --help
that I pasted above directly on this mail thread?
I haven't checked the actual man pages yet, so I can't comment on that.
Below is the current output of man gnunet-search
(we should also update the date at the bottom, currently “February 25, 2012”)
--madmurphy
GNUNET-SEARCH(1) BSD General Commands Manual GNUNET-SEARCH(1)
NAME
gnunet-search — a command line interface to search for content on GNUnet
SYNOPSIS
gnunet-search [−a LEVEL | −-anonymity=LEVEL] [−b | −-bookmark-only] [−c FILENAME | −-config=FILENAME] [−F FORMAT | −-dir-printf=FORMAT] [−f FORMAT | −-printf=FORMAT] [−h | −-help] [−i FORMAT | −-iter-printf=FORMAT] [−L LOGLEVEL | −-loglevel=LOGLEVEL] [−l FILENAME | −-logfile=FILENAME] [−o FILENAME | −-output=FILENAME] [−n | −-no-network] [−N VALUE | −-results=VALUE] [−s | −-silent] [−t DELAY | −-timeout=DELAY] [−v | −-version] [−V | −-verbose] ⟨ KEYWORD ⟩ ⟨ +KEYWORD ⟩ | ⟨ URI ⟩ ⟨ +URI ⟩
DESCRIPTION
Search for content on GNUnet. The keywords are case-sensitive. gnunet-search can be used both for a search in the global namespace as well as for searching a private subspace. The options are as follows:
−a LEVEL | −-anonymity=LEVEL
This option can be used to specify additional anonymity constraints. The default is 1. If set to 0, GNUnet will publish the file non-anonymously and in fact sign the advertisement for the file using your peer’s private key. This will allow other users to download the file as fast as possible, including using non-anonymous methods (discovery via DHT and CADET transfer). If you set it to 1 (default), you use the standard anonymous routing algorithm (which does not explicitly leak your identity). However, a powerful adversary may still be able to perform traffic analysis (statistics) to over time discovery your identity. You can gain better privacy by specifying a higher level of anonymity (using values above 1). This tells FS that it must hide your own requests in equivalent-looking cover traffic. This should confound an adversaries traffic analysis, increasing the time and effort it would take to discover your identity. However, it also can significantly reduce performance, as your requests will be delayed until sufficient cover traffic is available. The specific numeric value (for anonymity levels above 1) is simple: Given an anonymity level L (above 1), each request FS makes on your behalf must be hidden in L-1 equivalent requests of cover traffic (traffic your peer routes for others) in the same time-period. The time-period is twice the average delay by which GNUnet artificially delays traffic. Note that regardless of the anonymity level you choose, peers that cache content in the network always use anonymity level 1.
−b | −-bookmark-only
Do not search, print only the URI that points to the search with the given keywords.
−c FILENAME | −-config=FILENAME
Use the configuration file FILENAME (default: ~/.config/gnunet.conf).
−F FORMAT | −-dir-printf=FORMAT
Write the search results for directories according to FORMAT. The directives supported here are identical to those supported in the −-printf argument (please refer to it for more information). If missing, −-dir-printf defaults to −-printf. If −-printf is missing too −-dir-printf defaults to ‘#%n:\ngnunet-download -o %f -R %u\n\n’.
−f FORMAT | −-printf=FORMAT
Write the search results according to FORMAT, in which ‘\’ and ‘%’ directives are interpreted as follows:
\\
a literal backslash (‘\’)
\a
an alarm bell
\b
a backspace
\e
an escape
\f
a form feed
\n
a newline
\r
a carriage return
\t
a horizontal tab
\v
a vertical tab
\0
an ASCII NUL.
\N...
the character whose ASCII code is N..., expressed in octal digits
\xX...
the character whose ASCII code is X..., expressed in hexadecimal digits
Note: The ‘\’ character followed by any other character not listed above is treated as an ordinary character, so both characters are printed.
%%
a percent sign
%a
the complete list of all the printable metadata properties available, displayed according to the −-iter-printf argument; this specifier optionally supports metatype filtering via hash sign (e.g. ‘%2#a’ prints all embedded file names, if present - see libextractor’s metatypes for the complete list of numerical identifiers)
%f
the file’s name
%j
the first printable metadata property available, displayed according to the −-iter-printf argument; this specifier optionally supports metatype filtering via hash sign (e.g. ‘%5#j’ prints a book title, if present); see libextractor’s metatypes for the complete list of numerical identifiers)
%l
the file name’s length
%m
the file’s mime type
%n
the search result number
%s
the file’s size in bytes
%u
the file’s URI
Note: The ‘%’ character followed by any other character not listed above is treated as an ordinary character, so both characters are printed.
If missing, −-printf defaults to ‘#%n:\ngnunet-download -o %f %u\n\n’.
−h | −-help
Print the help page.
−i FORMAT | −-iter-printf=FORMAT
When the ‘%a’ or ‘%j’ format specifiers appear in −-printf or −-dir-printf, list each metadata property according to FORMAT, in which the ‘\’ directives are interpreted as in −-printf and −-dir-printf, while the ‘%’ directives are interpreted as follows:
%%
a percent sign
%p
the property’s content
%l
the property content’s length in bytes
%i
the property type’s unique identifier
%n
the property number
%t
the property type (available only if compiled with libextractor)
%w
the name of the plugin that provided the information
Note: The ‘%’ character followed by any other character not listed above is treated as an ordinary character, so both characters are printed.
If missing, −-iter-printf defaults to ‘ %t: %p\n’ or ‘ MetaType #%i: %p\n’, depending on whether the program was compiled with libextractor or not.
−L LOGLEVEL | −-loglevel=LOGLEVEL
Change the loglevel. Possible values for LOGLEVEL are ERROR, WARNING, INFO and DEBUG.
−l FILENAME | −-logfile=FILENAME
Write logs to FILENAME.
−o FILENAME | −-output=FILENAME
Writes a GNUnet directory containing all of the search results to FILENAME (e.g. ‘gnunet-search --output=commons.gnd commons’).
−n | −-no-network
Only search locally, do not forward requests to other peers.
−N VALUE | −-results=VALUE
Automatically terminate the search after receiving VALUE results.
−s | −-silent
Enable silent mode and do not print any result (the −-output argument is required).
−t DELAY | −-timeout=DELAY
Automatically timeout search after DELAY. The value given must be a number followed by a space and a time unit, for example "500 ms". Note that the quotes are required on the shell. Without a unit it defaults to microseconds (1000000 = 1 second). If 0 or omitted the search runs until gnunet-search is aborted with CTRL-C.
−v | −-version
print the version number
−V | −-verbose
append ‘%a\n’ to the default −-printf and −-dir-printf arguments – ignored when these are provided by the user
It is possible to run gnunet-search with an URI instead of a keyword. The URI can have the format for a namespace search or for a keyword search. For a namespace search, the format is
gnunet://fs/sks/NAMESPACE/IDENTIFIER
For a keyword search, use
gnunet://fs/ksk/KEYWORD[+KEYWORD]*
If the format does not correspond to a GNUnet URI, GNUnet will automatically assume that keywords are supplied directly.
If multiple keywords are passed, gnunet-search will look for content matching any of the keywords. The ‘+’ prefix makes a keyword mandatory.
FILES
~/.config/gnunet.conf GNUnet configuration file; specifies the default value for the timeout
EXAMPLES
Example 1:
$ gnunet-search ’Das Kapital’
searches for content matching the keyword “Das Kapital”
Example 2:
$ gnunet-search Das Kapital
searches for content matching either keyword “Das” or keyword “Kapital”
Example 3:
$ gnunet-search +Das +Kapital
searches for content matching both mandatory keywords “Das” and “Kapital”
Search results are printed by gnunet-search like this:
gnunet-download -o "COPYING" gnunet://fs/chk/HASH1.HASH2.SIZE
Description: The GNU General Public License
Mime-type: text/plain
...
The first line contains the command to run to download the file. The suggested filename in the example is ‘COPYING’. The GNUnet URI consists of the key and query hash of the file and finally the size of the file. If the −-verbose option was provided, after the command to download the file, GNUnet will print metadata about the file as advertised in the search result. The metadata here is the description (“The GNU General Public License”) and the mime-type (“text-plain”). See the options for gnunet-publish(1) on how to supply metadata by hand.
SEE ALSO
gnunet-download(1), gnunet-fs-gtk(1), gnunet-publish(1), gnunet.conf(5)
The full documentation for GNUnet is maintained as a Texinfo manual. If the info(1) and gnunet packages are properly installed at your site, the command
info gnunet
should give you access to the complete handbook,
info gnunet-c-tutorial
will give you access to a tutorial for developers.
Depending on your installation, this information is also available in gnunet(7) and gnunet-c-tutorial(7).
BUGS
Report bugs by using https://bugs.gnunet.org or by sending electronic mail to ⟨ gnunet-developers@gnu.org⟩ .
BSD February 25, 2012 BSD
madmurphy <madmurphy333@gmail.com> writes:
> I have pushed the new gnunet-search with printf-like capabilities to
> the git repository. I have also updated the man page. Feel free to
> play with it and write your feedbacks :)
I think the help text when using `--help' is too long.
That's not really the place to write the _full_ explanation of the
option; that's the man page's job.
Even the tool's description should be reverted to the simpler one-liner
that was used previously.
The main reason is that it's so long to be basically unreadable.
As an example, the help string for `--printf', which other than being
about four sentences long also contains a list of items, should
probably be reworded like so:
"Write search results according to FORMAT.
See the documentation for the available placeholders."
Then you can add a dedicated section in the man page titled "Formatting
the output" or something like that.
`--dir-printf' should use the same string, instead of referencing some
other option. It is generally a good idea to treat each help message as
an independent entity — at least personally speaking, oftentimes I find
myself scanning the left column for a specific optiong and only after I
find it I read the help text, so having to navigate back and forth
because the option I need just says "alias for foo" ends up being rather
annoying in the long run.
I haven't checked the actual man pages yet, so I can't comment on that.
Thanks,
A.V.
[Prev in Thread] | Current Thread | [Next in Thread] |