diff --git a/README.markdown b/README.markdown index efce6c7..00096c3 100644 --- a/README.markdown +++ b/README.markdown @@ -78,6 +78,18 @@ performing the network requests manually. This is much more user friendly user interface. A single invocation can perform multiple requests depending on what subcommand you used. +The `pdc` client supports Bash completion if argcomplete Python package is installed. + +If you installed client from rpm package, the completion file `pdc.bash` has been +installed to `/etc/bash_completion.d/`. + +For developers or users who try to run `pdc` from source, to enable completion, +run this in your terminal (assuming pdc is somewhere on path). + + eval "$(register-python-argcomplete pdc)" + +or put `pdc.bash` to `/etc/bash_completion.d/`. + ## Python API When writing a client code interfacing with PDC server, you might find @@ -90,6 +102,7 @@ include - [requests](http://docs.python-requests.org/en/latest/) - [requests-kerberos](https://github.com/requests/requests-kerberos/) - [beanbag](http://beanbag.readthedocs.org/en/latest/) +- (Optional)[argcomplete](http://argcomplete.readthedocs.org/en/latest/_modules/argcomplete.html) Please find more details at: [`PDCClient`](pdc_client/__init__.py#L71) diff --git a/pdc-client.spec b/pdc-client.spec index 12eaf5a..a646aea 100644 --- a/pdc-client.spec +++ b/pdc-client.spec @@ -37,6 +37,9 @@ mkdir -p %{buildroot}%{_defaultdocdir}/pdc_client install -m 0644 -D -p bin/pdc_client %{buildroot}%{_bindir}/pdc_client install -m 0644 -D -p bin/pdc %{buildroot}%{_bindir}/pdc +# Install pdc bash argcompletion file +install -m 0644 -D -p pdc.bash %{buildroot}%{_sysconfdir}/bash_completion.d/pdc.bash + install -m 0644 -D -p docs/pdc_client.1 %{buildroot}%{_mandir}/man1/pdc_client.1 gzip %{buildroot}%{_mandir}/man1/pdc_client.1 @@ -46,6 +49,7 @@ gzip %{buildroot}%{_mandir}/man1/pdc_client.1 %attr(755, root, root) %{_bindir}/pdc_client %attr(755, root, root) %{_bindir}/pdc %{_mandir}/man1/pdc_client.1.gz +%{_sysconfdir}/bash_completion.d/pdc.bash %changelog diff --git a/pdc.bash b/pdc.bash new file mode 100644 index 0000000..36590cc --- /dev/null +++ b/pdc.bash @@ -0,0 +1,9 @@ + +_python_argcomplete() { + local IFS=' ' + COMPREPLY=( $(IFS="$IFS" COMP_LINE="$COMP_LINE" COMP_POINT="$COMP_POINT" _ARGCOMPLETE_COMP_WORDBREAKS="$COMP_WORDBREAKS" _ARGCOMPLETE=1 "$1" 8>&1 9>&2 1>/dev/null 2>/dev/null) ) + if [[ $? != 0 ]]; then + unset COMPREPLY + fi +} +complete -o nospace -o default -F _python_argcomplete "pdc" diff --git a/requirements/devel.txt b/requirements/devel.txt index 0e76624..4e4e361 100644 --- a/requirements/devel.txt +++ b/requirements/devel.txt @@ -2,3 +2,4 @@ mock flake8 coverage +argcomplete