the paraslash-0.4.9 release tarball
[paraslash.git] / command_util.sh
index f388b2cfb152db7cf34e0b2f84313ba26a209903..76b3445fc1557b607ef72ae9408dec38f8a54507 100755 (executable)
@@ -200,14 +200,6 @@ dump_proto()
        echo '/**'
        echo " * $desc_txt"
        echo ' *'
-       if [[ "$system_includes" =~ openssl/rc4.h ]]; then
-               echo ' * \param rc4c The rc4 crypt context.'
-       else
-               echo ' * \param fd The file descriptor to send output to.'
-       fi
-       echo ' * \param argc The number of arguments.'
-       echo ' * \param argv The argument vector.'
-       echo ' * '
        echo " * Usage: $usage_txt"
        echo ' * '
        echo "$help_txt" | sed -e 's/^/ * /g'
@@ -229,6 +221,7 @@ dump_proto()
 
 dump_array_member()
 {
+       local TAB='     '
        echo '{'
        echo ".name = \"$name_txt\","
        echo ".handler = com_$name_txt,"
@@ -238,10 +231,15 @@ dump_array_member()
        echo ".description = \"$desc_txt\","
        echo ".usage = \"$usage_txt\","
        echo ".help = "
-       printf "%s\n" "$help_txt" | sed -e 's/^/\"/g' -e 's/$/\\n\"/g'
+       printf "%s\n" "$help_txt" | sed -e 's/^/\"/g' -e 's/$/\\n\"/g' \
+               -e "s/$TAB/\\\t/g"
        echo '},'
 }
 
+dump_completion()
+{
+       echo "  {.name = \"$name_txt\", .completer = ${name_txt}_completer}, \\"
+}
 
 template_loop()
 {
@@ -255,11 +253,11 @@ template_loop()
        for member in $template_members; do
                local sed_cmd="sed -e s/@member@/$member/g"
                #echo "sed_cmd: $sed_cmd"
-               name_txt=$(echo $t_name | $sed_cmd)
+               name_txt=$(echo "$t_name" | $sed_cmd)
                #name_txt="$tname"
-               perms_txt=$(echo $t_perms | $sed_cmd)
-               desc_txt=$(echo $t_desc | $sed_cmd)
-               usage_txt=$(echo $t_usage | $sed_cmd)
+               perms_txt=$(echo "$t_perms" | $sed_cmd)
+               desc_txt=$(echo "$t_desc" | $sed_cmd)
+               usage_txt=$(echo "$t_usage" | $sed_cmd)
                help_txt=$(printf "%s\n" "$t_help" | $sed_cmd)
                prototype=$(echo "$template_prototype" | $sed_cmd)
                $1
@@ -311,6 +309,27 @@ com_header()
        done
 }
 
+com_completion()
+{
+
+       echo "#define $1 \\"
+       while : ; do
+               read_one_command
+               if test $ret -lt 0; then
+                       exit 1
+               fi
+               if test $ret -eq 0; then
+                       break
+               fi
+               if test $template -eq 0; then
+                       dump_completion
+                       continue
+               fi
+               template_loop dump_completion
+       done
+       echo
+}
+
 read_header
 arg="$1"
 shift
@@ -324,4 +343,7 @@ case "$arg" in
        "man")
                com_man $*
                ;;
+       "compl")
+               com_completion $*
+               ;;
 esac