support both bash and zsh autocompletion
@@ -36,65 +36,40 @@ Usage
Autocompletion
--------------
-You can activate autocompletion by copying this content into the file `/etc/bash_completion.d/substra` of your environment:
+Autocompletion files can be autogenerated by the tool [infi.docopt-completion](https://github.com/Infinidat/infi.docopt_completion/) for both bash and zsh shells.
+
+Install it in your python virtual environment
```bash
-_substra()
-{
- local cur prev opts commands
- COMPREPLY=()
- cur="${COMP_WORDS[COMP_CWORD]}"
- prev="${COMP_WORDS[COMP_CWORD-1]}"
- opts="--help -h --version"
- commands="config list add register update get bulk_update path create_project run_local"
-
- if [[ ${cur} == -* ]] ; then
- COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
- return 0
- fi
-
- case ${COMP_CWORD} in
- 1)
- COMPREPLY=($(compgen -W "${commands}" -- ${cur}))\
- ;;
- 2)
- case ${prev} in
- create_project)
- COMPREPLY=($(compgen -W "starter_kit isic" -- ${cur}))
- ;;
- list)
- COMPREPLY=($(compgen -W "algo objective data_manager model testtuple traintuple" -- ${cur}))
- ;;
- add)
- COMPREPLY=($(compgen -W "algo objective data_sample data_manager testtuple traintuple" -- ${cur}))
- ;;
- register)
- COMPREPLY=($(compgen -W "objective data_sample data_manager" -- ${cur}))
- ;;
- update)
- COMPREPLY=($(compgen -W "data_manager" -- ${cur}))
- ;;
- get)
- COMPREPLY=($(compgen -W "algo objective data_manager model testtuple traintuple" -- ${cur}))
- ;;
- bulk_update)
- COMPREPLY=($(compgen -W "data_sample" -- ${cur}))
- ;;
- path)
- COMPREPLY=($(compgen -W "model" -- ${cur}))
- ;;
- esac
- ;;
- *)
- COMPREPLY=()
- ;;
- esac
-}
-
-complete -F _substra substra
+pip install infi.docopt-completion
+```
+##### Bash
+
+After installing substra as a binary, run:
+``` bash
+docopt-completion substra --manual-bash
+Completion file written to ./substra.sh
+```
+
+Now move this file inside `/etc/bash_completion.d/`
+```bash
+sudo mv ./substra.sh /etc/bash_completion.d/
```
+Then source it with `source /etc/bash_completion`
+You now can enjoy autocompletion :tada:
-Then source it with `. /etc/bash_completion`
+#### Zsh
-You can test it by typing `substra l` and then pushing tab key.
-Enjoy!
+
+After installing substra as a binary, run:
+``` bash
+docopt-completion substra --manual-zsh
+Completion file written to ./_substra
+```
+
+Now move this file inside `/usr/share/zsh/functions/Completion`
+```bash
+sudo mv ./_substra /usr/share/zsh/functions/Completion
+```
+Then source it with `source ~/.zshrc`
+You now can enjoy autocompletion :tada:
