diff --git a/configure.ac b/configure.ac index 7b034853..85a8846e 100644 --- a/configure.ac +++ b/configure.ac @@ -173,6 +173,7 @@ AC_DEFUN([AC_DATAROOTDIR_CHECKED]) AC_OUTPUT([ Makefile man/Makefile +man/bash-completion/Makefile opl/Makefile opl/examples/Makefile pcsound/Makefile diff --git a/man/Makefile.am b/man/Makefile.am index f93e8ede..cf467d66 100644 --- a/man/Makefile.am +++ b/man/Makefile.am @@ -1,3 +1,5 @@ +SUBDIRS = bash-completion + MANPAGE_GEN_FILES = environ.man \ iwad_paths.man \ doom.template \ diff --git a/man/bash-completion/Makefile.am b/man/bash-completion/Makefile.am new file mode 100644 index 00000000..2b3d62a1 --- /dev/null +++ b/man/bash-completion/Makefile.am @@ -0,0 +1,42 @@ +BASH_COMPLETION_TEMPLATES = \ + doom.template \ + heretic.template \ + hexen.template \ + strife.template + +if HAVE_PYTHON + +BASH_COMPLETION_SCRIPTLETS = \ + @PROGRAM_PREFIX@doom \ + @PROGRAM_PREFIX@heretic \ + @PROGRAM_PREFIX@hexen \ + @PROGRAM_PREFIX@strife + +noinst_DATA = $(BASH_COMPLETION_SCRIPTLETS) +CLEANFILES = $(BASH_COMPLETION_SCRIPTLETS) + +MANDIR = $(top_srcdir)/man +DOCGEN = $(MANDIR)/docgen + +@PROGRAM_PREFIX@doom: $(top_srcdir)/src $(DOCGEN) $(BASH_COMPLETION_TEMPLATES) + $(DOCGEN) -g doom -b doom.template $(top_srcdir)/src $(top_srcdir)/src/doom > $@ + +@PROGRAM_PREFIX@heretic: $(top_srcdir)/src $(DOCGEN) $(BASH_COMPLETION_TEMPLATES) + $(DOCGEN) -g heretic -b heretic.template $(top_srcdir)/src $(top_srcdir)/src/heretic > $@ + +@PROGRAM_PREFIX@hexen: $(top_srcdir)/src $(DOCGEN) $(BASH_COMPLETION_TEMPLATES) + $(DOCGEN) -g hexen -b hexen.template $(top_srcdir)/src $(top_srcdir)/src/hexen > $@ + +@PROGRAM_PREFIX@strife: $(top_srcdir)/src $(DOCGEN) $(BASH_COMPLETION_TEMPLATES) + $(DOCGEN) -g strife -b strife.template $(top_srcdir)/src $(top_srcdir)/src/strife > $@ + +EXTRA_DIST = \ + $(BASH_COMPLETION_TEMPLATES) \ + $(BASH_COMPLETION_SCRIPTLETS) + +else + +EXTRA_DIST = \ + $(BASH_COMPLETION_TEMPLATES) + +endif diff --git a/man/bash-completion/chocolate-doom b/man/bash-completion/chocolate-doom deleted file mode 100644 index 280bc726..00000000 --- a/man/bash-completion/chocolate-doom +++ /dev/null @@ -1,58 +0,0 @@ -# bash completion for Chocolate Doom -*- shell-script -*- - -_chocolate_doom() -{ - local cur prev words cword - _init_completion || return - - case $prev in - -config|-extraconfig) - _filedir cfg - ;; - -episode) - COMPREPLY=(1 2 3 4) - ;; - -file|-iwad|-aa|-af|-as|-merge|-nwtmerge) - _filedir wad - ;; - -loadgame) - COMPREPLY=(0 1 2 3 4 5) - ;; - -pack) - COMPREPLY=(doom2 tnt plutonia) - ;; - -skill) - COMPREPLY=(1 2 3 4 5) - ;; - -gameversion) - COMPREPLY=(1.9 ultimate final final2 hacx chex) - ;; - -setmen) - COMPREPLY=(dos622 dos71 dosbox) - ;; - -playdemo|-timedemo) - _filedir lmp - ;; - -deh) - _filedir bex deh - ;; - esac - - if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '-1 -2 -3 -aa -af -altdeath -as -autojoin -avg - -cdrom -config -connect -deathmatch -dedicated -deh -dehlump -devparm - -donut -dumpsubstconfig -dup -episode -extraconfig -extratics -fast - -file -fullscreen -gameversion -geometry -grabmouse -height - -ignoreversion -iwad -left -loadgame -localsearch -longtics -maxdemo -mb - -merge -mmap -newsync -noblit -nocheats -nodeh -nodes -nodraw - -nograbmouse -nomonsters -nomouse -nomusic -nonovert -nosfx -nosound - -novert -nwtmerge -pack -playdemo -port -privateserver -query -record - -respawn -right -search -server -servername -setmem -skill -solo - -spechit -statdump -timedemo -timer -turbo -warp -width -window - -zonescan -zonezero ' -- "$cur" ) ) - fi -} && - -complete -F _chocolate_doom chocolate-doom chocolate-heretic chocolate-hexen chocolate-strife - -# ex: ts=4 sw=4 et filetype=sh diff --git a/man/bash-completion/doom.template b/man/bash-completion/doom.template new file mode 100644 index 00000000..35a15da3 --- /dev/null +++ b/man/bash-completion/doom.template @@ -0,0 +1,39 @@ +# bash completion for Chocolate Doom -*- shell-script -*- + +_chocolate_doom() +{ + local cur prev words cword + _init_completion || return + + case $prev in + -config|-extraconfig) + _filedir cfg + ;; + -file|-iwad|-aa|-af|-as|-merge|-nwtmerge) + _filedir wad + ;; + -pack) + COMPREPLY=(doom2 tnt plutonia) + ;; + -gameversion) + COMPREPLY=(1.9 ultimate final final2 hacx chex) + ;; + -setmen) + COMPREPLY=(dos622 dos71 dosbox) + ;; + -playdemo|-timedemo) + _filedir lmp + ;; + -deh) + _filedir bex deh + ;; + esac + + if [[ $cur == -* ]]; then + COMPREPLY=( $( compgen -W '@content' -- "$cur" ) ) + fi +} && + +complete -F _chocolate_doom chocolate-doom + +# ex: ts=4 sw=4 et filetype=sh diff --git a/man/bash-completion/heretic.template b/man/bash-completion/heretic.template new file mode 100644 index 00000000..84ea865c --- /dev/null +++ b/man/bash-completion/heretic.template @@ -0,0 +1,36 @@ +# bash completion for Chocolate Heretic -*- shell-script -*- + +_chocolate_heretic() +{ + local cur prev words cword + _init_completion || return + + case $prev in + -config|-extraconfig) + _filedir cfg + ;; + -file|-iwad|-aa|-af|-as|-merge|-nwtmerge) + _filedir wad + ;; + -hhever) + COMPREPLY=(1.0 1.2 1.3) + ;; + -setmen) + COMPREPLY=(dos622 dos71 dosbox) + ;; + -playdemo|-timedemo) + _filedir lmp + ;; + -deh) + _filedir hhe + ;; + esac + + if [[ $cur == -* ]]; then + COMPREPLY=( $( compgen -W '@content' -- "$cur" ) ) + fi +} && + +complete -F _chocolate_heretic chocolate-heretic + +# ex: ts=4 sw=4 et filetype=sh diff --git a/man/bash-completion/hexen.template b/man/bash-completion/hexen.template new file mode 100644 index 00000000..0b75a639 --- /dev/null +++ b/man/bash-completion/hexen.template @@ -0,0 +1,30 @@ +# bash completion for Chocolate Hexen -*- shell-script -*- + +_chocolate_hexen() +{ + local cur prev words cword + _init_completion || return + + case $prev in + -config|-extraconfig) + _filedir cfg + ;; + -file|-iwad|-aa|-af|-as|-merge|-nwtmerge) + _filedir wad + ;; + -setmen) + COMPREPLY=(dos622 dos71 dosbox) + ;; + -playdemo|-timedemo) + _filedir lmp + ;; + esac + + if [[ $cur == -* ]]; then + COMPREPLY=( $( compgen -W '@content' -- "$cur" ) ) + fi +} && + +complete -F _chocolate_hexen chocolate-hexen + +# ex: ts=4 sw=4 et filetype=sh diff --git a/man/bash-completion/strife.template b/man/bash-completion/strife.template new file mode 100644 index 00000000..c5f73758 --- /dev/null +++ b/man/bash-completion/strife.template @@ -0,0 +1,36 @@ +# bash completion for Chocolate Strife -*- shell-script -*- + +_chocolate_strife() +{ + local cur prev words cword + _init_completion || return + + case $prev in + -config|-extraconfig) + _filedir cfg + ;; + -file|-iwad|-aa|-af|-as|-merge|-nwtmerge) + _filedir wad + ;; + -gameversion) + COMPREPLY=(1.2 1.31) + ;; + -setmen) + COMPREPLY=(dos622 dos71 dosbox) + ;; + -playdemo|-timedemo) + _filedir lmp + ;; + -deh) + _filedir seh + ;; + esac + + if [[ $cur == -* ]]; then + COMPREPLY=( $( compgen -W '@content' -- "$cur" ) ) + fi +} && + +complete -F _chocolate_strife chocolate-strife + +# ex: ts=4 sw=4 et filetype=sh diff --git a/man/docgen b/man/docgen index 3b11ad8c..510c2ba2 100755 --- a/man/docgen +++ b/man/docgen @@ -106,6 +106,19 @@ class Category: return result + def completion_output(self): + result = "" + + self.params.sort() + + for p in self.params: + if p.should_show(): + result += p.completion_output(0) + + result = result.rstrip() + + return result + def manpage_output(self): result = ".SH " + self.description.upper() + "\n" @@ -278,6 +291,12 @@ class Parameter: return result + def completion_output(self, w): + + result = self.name + " " + + return result + # Read list of wiki pages def read_wikipages(): @@ -444,6 +463,15 @@ def plaintext_output(targets, template_file): print_template(template_file, content) +def completion_output(targets, template_file): + + content = "" + + for t in targets: + content += t.completion_output() + "\n" + + print_template(template_file, content) + def usage(): print("Usage: %s [-V] [-c tag] [-g game] ( -m | -w | -p )