Skip to content

Commit

Permalink
Add pdc bash completion file.
Browse files Browse the repository at this point in the history
Install `pdc.bash` to `/etc/bash_completion.d/`.

JIRA: PDC-1611
  • Loading branch information
xychu committed Dec 4, 2015
1 parent f6ed981 commit f097133
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
13 changes: 13 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand Down
4 changes: 4 additions & 0 deletions pdc-client.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
9 changes: 9 additions & 0 deletions pdc.bash
Original file line number Diff line number Diff line change
@@ -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"
1 change: 1 addition & 0 deletions requirements/devel.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
mock
flake8
coverage
argcomplete

0 comments on commit f097133

Please sign in to comment.