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

Commit973cb8b

Browse files
committed
feat: add autocompletion support
1 parent2a01326 commit973cb8b

File tree

3 files changed

+65
-0
lines changed

3 files changed

+65
-0
lines changed

‎docs/cli.rst

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,3 +271,61 @@ command line. This is handy for values containing new lines for instance:
271271
It is obviously the best project around
272272
EOF
273273
$ gitlab project create --name SuperProject --description @/tmp/description
274+
275+
Enabling shell autocompletion
276+
============================
277+
278+
To get autocompletion, you'll need to install the package with the extra
279+
"autocompletion":
280+
281+
..code-block::console
282+
283+
pip install python_gitlab[autocompletion]
284+
285+
286+
Add the appropriate command below to your shell's config file so that it is run on
287+
startup. You will likely have to restart or re-login for the autocompletion to
288+
start working.
289+
290+
Bash
291+
----
292+
293+
..code-block::console
294+
295+
eval "$(register-python-argcomplete gitlab)"
296+
297+
tcsh
298+
----
299+
300+
..code-block::console
301+
302+
eval `register-python-argcomplete --shell tcsh gitlab`
303+
304+
fish
305+
----
306+
307+
..code-block::console
308+
309+
register-python-argcomplete --shell fish gitlab | .
310+
311+
Zsh
312+
---
313+
314+
..warning::
315+
316+
Zsh autocompletion support is broken right now in the argcomplete python
317+
package. Perhaps it will be fixed in a future release of argcomplete at
318+
which point the following instructions will enable autocompletion in zsh.
319+
320+
To activate completions for zsh you need to have bashcompinit enabled in zsh:
321+
322+
..code-block::console
323+
324+
autoload -U bashcompinit
325+
bashcompinit
326+
327+
Afterwards you can enable completion for gitlab:
328+
329+
..code-block::console
330+
331+
eval "$(register-python-argcomplete gitlab)"

‎gitlab/cli.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,12 @@ def main():
172172

173173
# Now we build the entire set of subcommands and do the complete parsing
174174
parser=_get_parser(cli_module)
175+
try:
176+
importargcomplete
177+
178+
argcomplete.autocomplete(parser)
179+
exceptException:
180+
pass
175181
args=parser.parse_args(sys.argv[1:])
176182

177183
config_files=args.config_file

‎setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,5 @@ def get_version():
4545
"Programming Language :: Python :: 3.7",
4646
"Programming Language :: Python :: 3.8",
4747
],
48+
extras_require={"autocompletion": ["argcomplete>=1.10.0,<2"]},
4849
)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp