a Bash-script that performs a search through Fossil command-options.
This may be useful if you use Fossil, and less useful otherwise.
Fossil offers help per command/webpage using fossil help
<command>
,
but there is no real way to do keyword-search spanning help-pages.
(However, to display all available help in one single page, use the
/test-all-help
web-page on a running Fossil-instance, e.g.
http://fossil-scm.org/index.html/test-all-help. Note that this is a
so-called test-command, and thus subject to change/removal.)
Please read the script-header for more info, and use at will. I gave it the unhappy name 'fapropos' now; feel free to rename it :-)
#!/usr/bin/bash
# WHAT IS THIS?
#
# This script performs a search through Fossil command-options.
#
# CAVEAT
#
# The method to filter out options from the other text is feeble -
# only lines from help-pages beginning with whitespace are
# considered. This works reasonably well. Obviously, this tool is
# meant as a supplement to 'fossil help' only.
#
# SYNTAX
#
# fapropos <needle> [<whence>]
#
# <needle>: the string to search for
#
# <whence> an optional command-set specifier, e.g. "-t" for
# test-commands, or "-w" for WWW-commands. If not
# given, defaults to "-a" ("all commands").
F=fossil
needle=$1
shift
[ -n "$needle" ] || { echo "Use a search-string"; exit; }
whence=$*
[ -n "$whence" ] || whence="-a"
cmds=$( $F help $whence | xargs echo )
for c in $cmds; do
opts=$( $F help $c | grep '^ ' | grep -- "$needle" )
if [ -n "$opts" ]; then
echo $c:
echo "$opts" | sed 's/^ */ /'
echo
fi
done