Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: add autocompletion support#941

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
max-wittig merged 1 commit intopython-gitlab:masterfrommchlumsky:feat/autocompletion
Dec 17, 2019
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletionsdocs/cli.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -271,3 +271,61 @@ command line. This is handy for values containing new lines for instance:
It is obviously the best project around
EOF
$ gitlab project create --name SuperProject --description @/tmp/description

Enabling shell autocompletion
============================

To get autocompletion, you'll need to install the package with the extra
"autocompletion":

.. code-block:: console

pip install python_gitlab[autocompletion]


Add the appropriate command below to your shell's config file so that it is run on
startup. You will likely have to restart or re-login for the autocompletion to
start working.

Bash
----

.. code-block:: console

eval "$(register-python-argcomplete gitlab)"

tcsh
----

.. code-block:: console

eval `register-python-argcomplete --shell tcsh gitlab`

fish
----

.. code-block:: console

register-python-argcomplete --shell fish gitlab | .

Zsh
---

.. warning::

Zsh autocompletion support is broken right now in the argcomplete python
package. Perhaps it will be fixed in a future release of argcomplete at
which point the following instructions will enable autocompletion in zsh.

To activate completions for zsh you need to have bashcompinit enabled in zsh:

.. code-block:: console

autoload -U bashcompinit
bashcompinit

Afterwards you can enable completion for gitlab:

.. code-block:: console

eval "$(register-python-argcomplete gitlab)"
6 changes: 6 additions & 0 deletionsgitlab/cli.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -172,6 +172,12 @@ def main():

# Now we build the entire set of subcommands and do the complete parsing
parser = _get_parser(cli_module)
try:
import argcomplete

argcomplete.autocomplete(parser)
except Exception:
pass
args = parser.parse_args(sys.argv[1:])

config_files = args.config_file
Expand Down
1 change: 1 addition & 0 deletionssetup.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -45,4 +45,5 @@ def get_version():
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
],
extras_require={"autocompletion": ["argcomplete>=1.10.0,<2"]},
)

[8]ページ先頭

©2009-2025 Movatter.jp