summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2015-01-25 21:21:27 +0100
committerAleksander Morgado <aleksander@aleksander.es>2015-01-25 21:23:15 +0100
commit8423c70340fb2a13c0f7824a86aed25a8d12f78c (patch)
tree48c68718f36b5a7158d881c30dfb0ee57adaa9c1
parent688b094d3c56408fd6d8d202099ada294839b168 (diff)
downloadlibmbim-8423c70340fb2a13c0f7824a86aed25a8d12f78c.tar.gz
mbimcli: add command completion
https://bugs.freedesktop.org/show_bug.cgi?id=87901
-rw-r--r--src/mbimcli/Makefile.am12
-rw-r--r--src/mbimcli/mbimcli-completion83
2 files changed, 95 insertions, 0 deletions
diff --git a/src/mbimcli/Makefile.am b/src/mbimcli/Makefile.am
index 22313a4..4d77ebd 100644
--- a/src/mbimcli/Makefile.am
+++ b/src/mbimcli/Makefile.am
@@ -21,3 +21,15 @@ mbimcli_SOURCES = \
mbimcli_LDADD = \
$(MBIMCLI_LIBS) \
$(top_builddir)/src/libmbim-glib/libmbim-glib.la
+
+
+completiondir = $(datadir)/bash-completion/completions
+
+install-data-hook:
+ $(mkinstalldirs) $(DESTDIR)$(completiondir)
+ $(INSTALL_DATA) $(srcdir)/mbimcli-completion $(DESTDIR)$(completiondir)/mbimcli
+
+uninstall-hook:
+ rm -f $(DESTDIR)$(completiondir)/mbimcli
+
+EXTRA_DIST = mbimcli-completion
diff --git a/src/mbimcli/mbimcli-completion b/src/mbimcli/mbimcli-completion
new file mode 100644
index 0000000..a458cef
--- /dev/null
+++ b/src/mbimcli/mbimcli-completion
@@ -0,0 +1,83 @@
+# mbimcli(1) completion -*- shell-script -*-
+
+_mbimcli()
+{
+ local cur prev words cword split
+ _init_completion -s || return
+
+ case $prev in
+ '-d'|'--device')
+ _filedir
+ return 0
+ ;;
+ '--no-open')
+ COMPREPLY=( $(compgen -W "[Transaction-ID]" -- $cur) )
+ return 0
+ ;;
+ '--set-radio-state')
+ COMPREPLY=( $(compgen -W "[(on|off)]" -- $cur) )
+ return 0
+ ;;
+ '--enter-pin')
+ COMPREPLY=( $(compgen -W "[current-PIN]" -- $cur) )
+ return 0
+ ;;
+ '--change-pin')
+ COMPREPLY=( $(compgen -W "[(current-PIN),(new-PIN)]" -- $cur) )
+ return 0
+ ;;
+ '--enable-pin')
+ COMPREPLY=( $(compgen -W "[current-PIN]" -- $cur) )
+ return 0
+ ;;
+ '--disable-pin')
+ COMPREPLY=( $(compgen -W "[current-PIN]" -- $cur) )
+ return 0
+ ;;
+ '--enter-puk')
+ COMPREPLY=( $(compgen -W "[(PUK),(new-PIN)]" -- $cur) )
+ return 0
+ ;;
+ '--connect')
+ COMPREPLY=( $(compgen -W "[(APN),(PAP|CHAP|MSCHAPV2),(Username),(Password)]" -- $cur) )
+ return 0
+ ;;
+ '--phonebook-read')
+ COMPREPLY=( $(compgen -W "[(Phonebook-index)]" -- $cur) )
+ return 0
+ ;;
+ '--phonebook-write')
+ COMPREPLY=( $(compgen -W "[(Name),(Number)[,(Index)]]" -- $cur) )
+ return 0
+ ;;
+ '--phonebook-delete')
+ COMPREPLY=( $(compgen -W "[(Phonebook-index)]" -- $cur) )
+ return 0
+ ;;
+ '--dss-connect')
+ COMPREPLY=( $(compgen -W "[(UUID),(Session-ID)]" -- $cur) )
+ return 0
+ ;;
+ '--dss-disconnect')
+ COMPREPLY=( $(compgen -W "[(UUID),(Session-ID)]" -- $cur) )
+ return 0
+ ;;
+ '-V'|'--version')
+ return 0
+ ;;
+ '-h'|'--help'|'--help-all'|'--help-basic-connect'|'--help-phonebook'|'--help-dss'|'--help-ms-firmware-id'|'--help-ms-host-shutdown')
+ return 0
+ ;;
+ esac
+
+ $split && return 0
+
+ if [[ $cur == -* ]]; then
+ COMPREPLY=( $( compgen -W '$( _parse_help "$1" --help-all )' -- "$cur" ) )
+ [[ $COMPREPLY == *= ]] && compopt -o nospace
+ return 0
+ fi
+} &&
+complete -F _mbimcli mbimcli
+
+# ex: ts=4 sw=4 et filetype=sh