2005-09-15 09:58:31 -04:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# Script used to generate doc/book/config/cmdoptions.xml
|
|
|
|
# and hopefully other in the future.
|
|
|
|
|
|
|
|
# Updated by option handlind via --elinks=path/to/elinks option
|
2006-01-12 02:33:50 -05:00
|
|
|
elinks="$1"
|
|
|
|
option="$2"
|
2005-09-15 09:58:31 -04:00
|
|
|
|
|
|
|
# Option handling {{{1
|
|
|
|
|
|
|
|
command=
|
|
|
|
|
2006-01-12 02:33:50 -05:00
|
|
|
case "$option" in
|
|
|
|
*command*)
|
|
|
|
filter="sed 0,/^Options:/d"
|
|
|
|
option=--long-help
|
|
|
|
;;
|
|
|
|
*config*)
|
|
|
|
filter="sed 0,/^Configuration/d"
|
|
|
|
option=--config-help
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
print_description_line()
|
2005-09-15 09:58:31 -04:00
|
|
|
{
|
|
|
|
line="$1"
|
|
|
|
number="$2"
|
|
|
|
|
|
|
|
case "$line" in
|
|
|
|
-eval*)
|
|
|
|
echo
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
line="$(echo $line | sed 's,\(-touch-files\|-no-connect\|-session-ring\|-dump\|-default-mime-type\|text/html\|~/\.elinks\),\`\1\`,g')"
|
|
|
|
line=$(echo $line | sed "s,'\([^']*\)',\\\'\1\\\',")
|
|
|
|
line=$(echo $line | sed "s,ELinks,'ELinks',g")
|
|
|
|
line=$(echo $line | sed "s,HOME,'HOME',g")
|
|
|
|
line="$(echo $line | sed 's/^\([a-zA-Z]*([^)]*)\).*:/- \`\1\`:/')"
|
|
|
|
|
|
|
|
if test -n "$number";
|
|
|
|
then
|
|
|
|
echo -n " - $number:"
|
|
|
|
fi
|
|
|
|
esac
|
|
|
|
echo " $line"
|
|
|
|
}
|
|
|
|
|
2006-01-12 02:33:50 -05:00
|
|
|
print_option_tree()
|
2005-09-15 09:58:31 -04:00
|
|
|
{
|
2006-01-12 02:33:50 -05:00
|
|
|
title="$1"
|
|
|
|
path="$2"
|
|
|
|
echo "$path::"
|
2005-09-15 09:58:31 -04:00
|
|
|
}
|
|
|
|
|
2006-01-12 02:33:50 -05:00
|
|
|
print_option_type()
|
2005-09-15 09:58:31 -04:00
|
|
|
{
|
|
|
|
path="$1"
|
|
|
|
typeid="$2"
|
|
|
|
default="$3"
|
|
|
|
typestring="$path"
|
|
|
|
if test -n "$typeid" && test "$typeid" != "$path";
|
|
|
|
then
|
|
|
|
if test "$typeid" = "(alias";
|
|
|
|
then
|
|
|
|
typestring="$typestring ($default)"
|
|
|
|
default=
|
|
|
|
else
|
|
|
|
typestring="$typestring $typeid"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if test -n "$default" && test "$default" != "$path";
|
|
|
|
then
|
|
|
|
typestring="$typestring ($default)"
|
|
|
|
fi
|
|
|
|
if test "$default" = "-?, -h, -help";
|
|
|
|
then
|
|
|
|
typestring="$default"
|
|
|
|
fi
|
|
|
|
|
2006-01-12 02:33:50 -05:00
|
|
|
echo "$typestring::"
|
2005-09-15 09:58:31 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# The main loop {{{1
|
|
|
|
|
|
|
|
# State variables
|
|
|
|
parse_description=
|
|
|
|
parse_int_option=
|
|
|
|
use_log=
|
|
|
|
|
2006-01-12 02:33:50 -05:00
|
|
|
"$elinks" $option | $filter | while read line
|
2005-09-15 09:58:31 -04:00
|
|
|
do
|
|
|
|
if test -n "$parse_description"
|
|
|
|
then
|
|
|
|
# If the line is empty it is our clue that
|
|
|
|
# the desciption is over.
|
|
|
|
if test -z "$line"
|
|
|
|
then
|
2006-01-12 04:29:05 -05:00
|
|
|
echo
|
2005-09-15 09:58:31 -04:00
|
|
|
parse_description=
|
|
|
|
parse_int_option=
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
|
|
|
line=`echo "$line" | sed -e "s/[ ]*(DISABLED)//"`
|
|
|
|
number=
|
|
|
|
if test -n "$parse_int_option";
|
|
|
|
then
|
|
|
|
case "$line" in
|
|
|
|
-[0-9]*)
|
|
|
|
number="`echo $line | sed -e 's/\(-[0-9-]*\).*/\1/'`"
|
|
|
|
line=`echo "$line" | sed -e "s/$number[ ]*//"`
|
|
|
|
;;
|
|
|
|
|
|
|
|
[0-9]*)
|
|
|
|
number="`echo $line | sed -e 's/\([0-9-]*\).*/\1/'`"
|
|
|
|
line=`echo "$line" | sed -e "s/$number[ ]*//"`
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
2006-01-12 02:33:50 -05:00
|
|
|
print_description_line "$line" "$number"
|
2005-09-15 09:58:31 -04:00
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
|
|
|
case "$line" in
|
|
|
|
Features:*)
|
|
|
|
;;
|
2006-01-03 09:17:23 -05:00
|
|
|
[A-Z]*:" ("*[a-z]*)
|
2005-09-15 09:58:31 -04:00
|
|
|
parse_description=1
|
|
|
|
title="`echo $line | sed -e 's/\([A-Z]*\):.*/\1/'`"
|
|
|
|
path="`echo $line | sed -e 's/.*: (\([a-z_].*\))/\1/'`"
|
2006-01-12 02:33:50 -05:00
|
|
|
print_option_tree "$title" "$path"
|
2005-09-15 09:58:31 -04:00
|
|
|
;;
|
|
|
|
|
|
|
|
[a-z_-]*[.a-z_-]*)
|
|
|
|
parse_description=1
|
|
|
|
path="`echo $line | sed -e 's/\([a-z-][^ ]*\).*/\1/'`"
|
|
|
|
typeid="`echo $line | sed -e 's/[ ]*[a-z-][^ ]* \([^ ]*\).*/\1/'`"
|
|
|
|
default="`echo \"$line\" | sed -e 's/[^(]*(\(.*\))/\1/'`"
|
2006-01-12 02:33:50 -05:00
|
|
|
print_option_type "$path" "$typeid" "$default"
|
2005-09-15 09:58:31 -04:00
|
|
|
if test "$typeid" = "<num>";
|
|
|
|
then
|
|
|
|
parse_int_option=1
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2006-01-12 02:33:50 -05:00
|
|
|
version="`$elinks -version | head -n 1 | sed -e 's/ELinks \([0-9][^ ]*\).*/\1/'`"
|
|
|
|
echo "Generated using output from ELinks version $version."
|
|
|
|
|
2005-09-15 09:58:31 -04:00
|
|
|
|
|
|
|
# vim: tabstop=4 shiftwidth=4
|