Skip to content

Commit

Permalink
Client will install bash completion file.
Browse files Browse the repository at this point in the history
JIRA: PDC-1161
  • Loading branch information
zkl94 committed Nov 13, 2015
1 parent 05280ef commit 11d000c
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 9 deletions.
6 changes: 6 additions & 0 deletions docs/source/pdc_client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ requests manually.
This is much more user friendly user interface. A single invocation can perform
multiple requests depending on what subcommand you used.

Although auto-completion is inherently enabled for pdc, it will be disabled if
`python-argcomplete` is not installed. To enable it, install `python-argcomplete`
and activate by typing `activate-global-python-argcomplete` in command line.
Please note that by doing this only global completion is enabled which is
currently not compatible with zsh.


Python API
----------
Expand Down
1 change: 1 addition & 0 deletions pdc_client/bin/pdc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#! /usr/bin/env python
# PYTHON_ARGCOMPLETE_OK
# -*- coding: utf-8 -*-
#
# Copyright (c) 2015 Red Hat
Expand Down
1 change: 0 additions & 1 deletion pdc_client/pdc-client.spec
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ gzip %{buildroot}%{_mandir}/man1/pdc_client.1
%attr(755, root, root) %{_bindir}/pdc
%{_mandir}/man1/pdc_client.1.gz


%changelog
* Fri Sep 11 2015 Xiangyang Chu <xychu2008@gmail.com> 0.1.0-1
- new package built with tito
Expand Down
8 changes: 8 additions & 0 deletions pdc_client/pdc_bash_completion
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
_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"
9 changes: 1 addition & 8 deletions pdc_client/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,7 @@
import logging
import imp

# The client supports Bash completion if argcomplete Python package is
# installed. To enable it, run this in your terminal (assuming pdc is somewhere
# on path).
#
# eval "$(register-python-argcomplete pdc)"
#
# This is only a temporary solution, when the client is packaged, a completion
# file should be shipped with it and installed to /etc/bash_completion.d/.
# The client supports Bash completion if argcomplete Python package is installed.
try:
import argcomplete
except ImportError:
Expand Down

0 comments on commit 11d000c

Please sign in to comment.