Add bash-completion scripts for the libabigail tools
authorOndrej Oprala <ooprala@redhat.com>
Sat, 14 Nov 2015 17:32:01 +0000 (18:32 +0100)
committerOndrej Oprala <ooprala@redhat.com>
Mon, 23 Nov 2015 07:18:48 +0000 (08:18 +0100)
* Makefile.am: include bash-completion/Makefile.am
* bash-completion/Makefile.am: New makefile for the bash-completion
directory.
* bash-completion/abicompat: New completion script.
* bash-completion/abidiff: Likewise.
* bash-completion/abidw: Likewise.
* bash-completion/abilint: Likewise.
* bash-completion/abinilint: Likewise.
* bash-completion/abipkgdiff: Likewise.
* bash-completion/abisym: Likewise.
* configure.ac: Check for the bash-completion package. Handle
the new --enable-bash-completion[=WHEN] configure option.
* manuals/libabigail-tools.rst: Mention the scripts.

Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
Makefile.am
bash-completion/Makefile.am [new file with mode: 0644]
bash-completion/abicompat [new file with mode: 0755]
bash-completion/abidiff [new file with mode: 0755]
bash-completion/abidw [new file with mode: 0755]
bash-completion/abilint [new file with mode: 0755]
bash-completion/abinilint [new file with mode: 0755]
bash-completion/abipkgdiff [new file with mode: 0755]
bash-completion/abisym [new file with mode: 0755]
configure.ac
doc/manuals/libabigail-tools.rst

index ac1a57a..2015ef8 100644 (file)
@@ -1,4 +1,4 @@
-SUBDIRS = include src tools tests doc
+SUBDIRS = include src tools tests doc bash-completion
 ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
 headers = config.h
 
@@ -8,6 +8,9 @@ m4data_DATA = $(srcdir)/abigail.m4
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = libabigail.pc
 
+#bashcompletiondir = $(datadir)/bash-completion/completions
+#dist_bashcompletion_DATA =
+
 EXTRA_DIST =                   \
 README COPYING ChangeLog       \
 COPYING-LGPLV2 COPYING-LGPLV3  \
diff --git a/bash-completion/Makefile.am b/bash-completion/Makefile.am
new file mode 100644 (file)
index 0000000..aa16261
--- /dev/null
@@ -0,0 +1,10 @@
+#if ENABLE_BASH_COMPLETION
+EXTRA_DIST = \
+abicompat \
+abidiff \
+abidw \
+abilint \
+abinilint \
+abipkgdiff \
+abisym
+#endif
diff --git a/bash-completion/abicompat b/bash-completion/abicompat
new file mode 100755 (executable)
index 0000000..cb4663a
--- /dev/null
@@ -0,0 +1,48 @@
+_abicompat_module()
+{
+       local cur prev OPTS
+       COMPREPLY=()
+       cur="${COMP_WORDS[COMP_CWORD]}"
+       prev="${COMP_WORDS[COMP_CWORD-1]}"
+       case $prev in
+         '--app-debug-info-dir'|'--lib-debug-info-dir1'|'--lib-debug-info-dir2')
+           local IFS=$'\n'
+           compopt -o dirnames
+           COMPREPLY=( $(compgen -d -- $cur) )
+           return 0
+           ;;
+         '--suppressions')
+           local IFS=$'\n'
+           compopt -o filenames
+           COMPREPLY=( $(compgen -f -- $cur) )
+           return 0
+           ;;
+         '--drop' | '--drop-fn' | '--drop-var' | '--keep' | '--keep-fn' | '--keep-var')
+         #'--{drop,keep}{,-fn,-var}')
+           COMPREPLY=( $(compgen -W "string" -- $cur) )
+           return 0
+           ;;
+       esac
+       case $cur in
+         -*)
+               #TODO: not done, short options missing etc..
+           OPTS="  --app-debug-info-dir1
+                   --help
+                   --lib-debug-info-dir1
+                   --lib-debug-info-dir2
+                   --list-undefined-symbols
+                   --no-redundant
+                   --redundant
+                   --show-base-names
+                   --suppressions
+                   --weak-mode"
+           COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+           return 0
+           ;;
+       esac
+       local IFS=$'\n'
+       compopt -o filenames
+       COMPREPLY=( $(compgen -f -- $cur) )
+       return 0
+}
+complete -F _abicompat_module abicompat
diff --git a/bash-completion/abidiff b/bash-completion/abidiff
new file mode 100755 (executable)
index 0000000..5a2b551
--- /dev/null
@@ -0,0 +1,63 @@
+_abidiff_module()
+{
+       local cur prev OPTS
+       COMPREPLY=()
+       cur="${COMP_WORDS[COMP_CWORD]}"
+       prev="${COMP_WORDS[COMP_CWORD-1]}"
+       case $prev in
+         '--d1'|'--d2'|'--debug-info-dir1'|'--debug-info-dir2')
+           local IFS=$'\n'
+           compopt -o dirnames
+           COMPREPLY=( $(compgen -d -- $cur) )
+           return 0
+           ;;
+         '--suppressions'|'--suppr')
+           local IFS=$'\n'
+           compopt -o filenames
+           COMPREPLY=( $(compgen -f -- $cur) )
+           return 0
+           ;;
+         '--drop' | '--drop-fn' | '--drop-var' | '--keep' | '--keep-fn' | '--keep-var')
+         #'--{drop,keep}{,-fn,-var}')
+           COMPREPLY=( $(compgen -W "string" -- $cur) )
+           return 0
+           ;;
+       esac
+       case $cur in
+         -*)
+           OPTS="  --added-fns
+                   --added-vars
+                   --changed-fns
+                   --changed-vars
+                   --d1
+                   --d2
+                   --debug-info-dir1
+                   --debug-info-dir2
+                   --deleted-fns
+                   --deleted-vars
+                   --drop
+                   --drop-fn
+                   --drop-var
+                   --dump-diff-tree
+                   --harmless
+                   --help
+                   --keep
+                   --keep-fn
+                   --keep-var
+                   --no-harmful
+                   --no-linkage-name
+                   --no-redundant
+                   --no-unreferenced-symbols
+                   --redundant
+                   --stat
+                   --symtabs"
+           COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+           return 0
+           ;;
+       esac
+       local IFS=$'\n'
+       compopt -o filenames
+       COMPREPLY=( $(compgen -f -- $cur) )
+       return 0
+}
+complete -F _abidiff_module abidiff
diff --git a/bash-completion/abidw b/bash-completion/abidw
new file mode 100755 (executable)
index 0000000..004e4e1
--- /dev/null
@@ -0,0 +1,49 @@
+_abidw_module()
+{
+       local cur prev OPTS
+       COMPREPLY=()
+       cur="${COMP_WORDS[COMP_CWORD]}"
+       prev="${COMP_WORDS[COMP_CWORD-1]}"
+       case $prev in
+         '-d'|'--debug-info-dir')
+           local IFS=$'\n'
+           compopt -o dirnames
+           COMPREPLY=( $(compgen -d -- $cur) )
+           return 0
+           ;;
+         '--check-alternative-debug-info' | '--check-alternative-debug-info-base-name')
+           # TODO: perhaps limit this to ar-s and elf-s
+           local IFS=$'\n'
+           compopt -o filenames
+           COMPREPLY=( $(compgen -f -- $cur) )
+           return 0
+           ;;
+         '--out-file')
+           local IFS=$'\n'
+           compopt -o filenames
+           COMPREPLY=( $(compgen -f -- $cur) )
+           return 0
+           ;;
+       esac
+       case $cur in
+         -*)
+           OPTS="  --abidiff
+                   --debug-info-dir
+                   --check-alternative-debug-info
+                   --check-alternative-debug-info-base-name
+                   --help
+                   --load-all-types
+                   --no-architecture
+                   --noout
+                   --out-file
+                   --stats"
+           COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+           return 0
+           ;;
+       esac
+       local IFS=$'\n'
+       compopt -o filenames
+       COMPREPLY=( $(compgen -f -- $cur) )
+       return 0
+}
+complete -F _abidw_module abidw
diff --git a/bash-completion/abilint b/bash-completion/abilint
new file mode 100755 (executable)
index 0000000..7df78d1
--- /dev/null
@@ -0,0 +1,32 @@
+_abilint_module()
+{
+       local cur prev OPTS
+       COMPREPLY=()
+       cur="${COMP_WORDS[COMP_CWORD]}"
+       prev="${COMP_WORDS[COMP_CWORD-1]}"
+       case $prev in
+         '-d'|'--debug-info-dir')
+           local IFS=$'\n'
+           compopt -o dirnames
+           COMPREPLY=( $(compgen -d -- $cur) )
+           return 0
+           ;;
+       esac
+       case $cur in
+         -*)
+           OPTS="  --idiff
+                   --debug-info-dir
+                   --help
+                   --noout
+                   --stdin
+                   --tu"
+           COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+           return 0
+           ;;
+       esac
+       local IFS=$'\n'
+       compopt -o filenames
+       COMPREPLY=( $(compgen -f -- $cur) )
+       return 0
+}
+complete -F _abilint_module abilint
diff --git a/bash-completion/abinilint b/bash-completion/abinilint
new file mode 100755 (executable)
index 0000000..137b839
--- /dev/null
@@ -0,0 +1,21 @@
+_abinilint_module()
+{
+       local cur prev OPTS
+       COMPREPLY=()
+       cur="${COMP_WORDS[COMP_CWORD]}"
+       prev="${COMP_WORDS[COMP_CWORD-1]}"
+       case $cur in
+         -*)
+           OPTS="  --help
+                   --noout
+                   --from-stdin"
+           COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+           return 0
+           ;;
+       esac
+       local IFS=$'\n'
+       compopt -o filenames
+       COMPREPLY=( $(compgen -f -- $cur) )
+       return 0
+}
+complete -F _abinilint_module abinilint
diff --git a/bash-completion/abipkgdiff b/bash-completion/abipkgdiff
new file mode 100755 (executable)
index 0000000..142d987
--- /dev/null
@@ -0,0 +1,45 @@
+_abipkgdiff_module()
+{
+       local cur prev OPTS
+       COMPREPLY=()
+       cur="${COMP_WORDS[COMP_CWORD]}"
+       prev="${COMP_WORDS[COMP_CWORD-1]}"
+       case $prev in
+         '--d1'|'--d2'|'--debug-info-dir1'|'--debug-info-dir2')
+           local IFS=$'\n'
+           compopt -o dirnames
+           COMPREPLY=( $(compgen -d -- $cur) )
+           return 0
+           ;;
+         '--suppressions'|'--suppr')
+           local IFS=$'\n'
+           compopt -o filenames
+           COMPREPLY=( $(compgen -f -- $cur) )
+           return 0
+           ;;
+       esac
+       case $cur in
+         -*)
+           OPTS="  --d1
+                   --d2
+                   --debug-info-dir1
+                   --debug-info-dir2
+                   --dso-only
+                   --help
+                   --keep-tmp-files
+                   --no-added-binaries
+                   --no-linkage-name
+                   --redundant
+                   --suppr
+                   --suppressions
+                   --verbose"
+           COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+           return 0
+           ;;
+       esac
+       local IFS=$'\n'
+       compopt -o filenames
+       COMPREPLY=( $(compgen -f -- $cur) )
+       return 0
+}
+complete -F _abipkgdiff_module abipkgdiff
diff --git a/bash-completion/abisym b/bash-completion/abisym
new file mode 100755 (executable)
index 0000000..dff4986
--- /dev/null
@@ -0,0 +1,21 @@
+_abisym_module()
+{
+       local cur prev OPTS
+       COMPREPLY=()
+       cur="${COMP_WORDS[COMP_CWORD]}"
+       prev="${COMP_WORDS[COMP_CWORD-1]}"
+       case $cur in
+         -*)
+           OPTS="  --help
+                   --demangle
+                   --no-absolute-path"
+           COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+           return 0
+           ;;
+       esac
+       local IFS=$'\n'
+       compopt -o filenames
+       COMPREPLY=( $(compgen -f -- $cur) )
+       return 0
+}
+complete -F _abisym_module abisym
index 096a762..e1ccdc8 100644 (file)
@@ -70,6 +70,12 @@ AC_ARG_ENABLE(manual,
              ENABLE_MANUAL=$enableval,
              ENABLE_MANUAL=auto)
 
+AC_ARG_ENABLE([bash-completion],
+             AS_HELP_STRING([--enable-bash-completion=yes|no|auto],
+                            [enable using completion files for tools]),
+             ENABLE_BASH_COMPLETION=$enableval,
+             ENABLE_BASH_COMPLETION=auto)
+
 dnl *************************************************
 dnl check for dependencies
 dnl *************************************************
@@ -191,6 +197,25 @@ fi
 
 AM_CONDITIONAL(ENABLE_TAR, test x$ENABLE_TAR = xyes)
 
+dnl Check for the bash-completion package
+if test x$ENABLE_BASH_COMPLETION = xauto -o x$ENABLE_BASH_COMPLETION = xyes; then
+   AC_CHECK_PROG(HAS_BASH_COMPLETION, bash-completion, yes, no)
+
+   if test x$ENABLE_BASH_COMPLETION = xauto; then
+     if test x$HAS_BASH_COMPLETION = xyes; then
+       ENABLE_BASH_COMPLETION=yes
+    fi
+   fi
+fi
+
+if test x$ENABLE_BASH_COMPLETION = xyes; then
+   AC_MSG_NOTICE(bash-completion support in libabigail is enabled);
+else
+   AC_MSG_NOTICE(bash-completion support in libabigail is disabled);
+fi
+
+AM_CONDITIONAL(ENABLE_BASH_COMPLETION, test x$ENABLE_BASH_COMPLETION = xyes)
+
 dnl Check for dependency: libzip
 LIBZIP_VERSION=0.10.1
 
@@ -329,7 +354,8 @@ libabigail.pc
   src/Makefile
   tools/Makefile
   tests/Makefile
-    tests/data/Makefile])
+    tests/data/Makefile
+    bash-completion/Makefile])
 
 dnl Some test scripts are generated by autofoo.
 AC_CONFIG_FILES([tests/runtestcanonicalizetypes.sh], [chmod +x tests/runtestcanonicalizetypes.sh])
@@ -354,6 +380,7 @@ AC_MSG_NOTICE([
     Enable rpm support in abipkgdiff               : ${ENABLE_RPM}
     Enable deb support in abipkgdiff               : ${ENABLE_DEB}
     Enable GNU tar archive support in abipkgdiff   : ${ENABLE_TAR}
+    Enable bash completion                        : ${ENABLE_BASH_COMPLETION}
     Generate html apidoc                          : ${ENABLE_APIDOC}
     Generate html manual                          : ${ENABLE_MANUAL}
 ])
index ad5e90b..2f7f4c1 100644 (file)
@@ -7,7 +7,7 @@ Overview
 
 The upstream code repository of Libabigail contains several tools
 written using the library.  They are maintained and released as part
-of the project.
+of the project.  All tools come with a bash-completion script.
 
 Tools manuals
 =============