]> git.tue.mpg.de Git - paraslash.git/commitdiff
Teach command_util to print also completions.
authorAndre Noll <maan@systemlinux.org>
Sun, 28 Aug 2011 04:34:55 +0000 (06:34 +0200)
committerAndre Noll <maan@systemlinux.org>
Sun, 20 Nov 2011 14:08:41 +0000 (15:08 +0100)
This adds completion mode to command_util.sh. When exectuted in this
mode, it prints array initializers for all supported commands. This
will be used to generate the array of completers for para_client and
para_audiod.

.gitignore
Doxyfile
Makefile.in
command_util.sh

index 91c6f8589b600c26b00e845fa4413b85ba038944..d337367bfe0325eeb6caa6b6f6982eb35bdb14c2 100644 (file)
@@ -31,3 +31,4 @@ confdefs.h
 conftest
 conftest.c
 git-version.h
+*_completion.h
index 81e414d5609c8408aec577a0524f3e3f4d10afe4..83973cfb9dc23c6d6eaacb2efe7406c74d6b5d73 100644 (file)
--- a/Doxyfile
+++ b/Doxyfile
@@ -623,7 +623,8 @@ EXCLUDE_PATTERNS       = *.cmdline.* \
                          gcc-compat.h \
                          fade.c \
                          config.h \
-                       *_command_list.[ch]
+                       *_command_list.[ch] \
+                       *_completion.h
 
 # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
 # (namespaces, classes, functions, etc.) that should be excluded from the
index 23ceda47a1db0cb2460c2656c4bcbd89cdbbd165..cf9598f71a0da39073d9dba6b8e85b9be5e4cbca 100644 (file)
@@ -109,6 +109,15 @@ tarball: $(tarball)
 
 -include $(ggo_dir)/makefile
 
+# When in doubt, use brute force (Ken Thompson)
+TOUPPER = \
+$(subst a,A,$(subst b,B,$(subst c,C,$(subst d,D,$(subst e,E,\
+$(subst f,F,$(subst g,G,$(subst h,H,$(subst i,I,$(subst j,J,\
+$(subst k,K,$(subst l,L,$(subst m,M,$(subst n,N,$(subst o,O,\
+$(subst p,P,$(subst q,Q,$(subst r,R,$(subst s,S,$(subst t,T,\
+$(subst u,U,$(subst v,V,$(subst w,W,$(subst x,X,$(subst y,Y,\
+$(subst z,Z,$1))))))))))))))))))))))))))
+
 %_command_list.c: %.cmd
        @[ -z "$(Q)" ] || echo 'GEN $@'
        $(Q) ./command_util.sh c < $< >$@
@@ -118,6 +127,10 @@ tarball: $(tarball)
 %_command_list.man: %.cmd
        @[ -z "$(Q)" ] || echo 'GEN $@'
        $(Q) ./command_util.sh man < $< > $@
+%_completion.h: %.cmd
+       @[ -z "$(Q)" ] || echo 'GEN $@'
+       $(Q) ./command_util.sh compl $(strip $(call TOUPPER,$(*F)))_COMPLETERS \
+               $(strip $(call TOUPPER,$(*F)))_COMMANDS < $< > $@
 
 server_command_lists_man = server_command_list.man afs_command_list.man
 man/man1/para_server.1: para_server $(server_command_lists_man) | $(man_dir)
@@ -283,8 +296,7 @@ clean:
 clean2: clean
        @[ -z "$(Q)" ] || echo 'CLEAN2'
        $(Q) rm -rf man $(object_dir) $(cmdline_dir)
-       $(Q) rm -f *_command_list.* $(ggo_generated)
-
+       $(Q) rm -f *_command_list.* *_completion.h $(ggo_generated)
 distclean: clean2 test-clean
        @[ -z "$(Q)" ] || echo 'DISTCLEAN'
        $(Q) rm -f Makefile autoscan.log config.status config.log
index 86e0125865fdb24ceb1b42189430e7f5d31416c5..76b3445fc1557b607ef72ae9408dec38f8a54507 100755 (executable)
@@ -236,6 +236,10 @@ dump_array_member()
        echo '},'
 }
 
+dump_completion()
+{
+       echo "  {.name = \"$name_txt\", .completer = ${name_txt}_completer}, \\"
+}
 
 template_loop()
 {
@@ -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