gui: Rename client_cmd_cmdline() to para_cmd().
[paraslash.git] / command_util.sh
index 8f82b39318103dd73b44315ddaa3548912320bbc..76b3445fc1557b607ef72ae9408dec38f8a54507 100755 (executable)
@@ -236,6 +236,10 @@ dump_array_member()
        echo '},'
 }
 
+dump_completion()
+{
+       echo "  {.name = \"$name_txt\", .completer = ${name_txt}_completer}, \\"
+}
 
 template_loop()
 {
@@ -249,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
@@ -305,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
@@ -318,4 +343,7 @@ case "$arg" in
        "man")
                com_man $*
                ;;
+       "compl")
+               com_completion $*
+               ;;
 esac