File tree Expand file tree Collapse file tree 3 files changed +65
-0
lines changed
Expand file tree Collapse file tree 3 files changed +65
-0
lines changed Original file line number Diff line number Diff 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)"
Original file line number Diff line number Diff 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+ import argcomplete
177+
178+ argcomplete .autocomplete (parser )
179+ except Exception :
180+ pass
175181 args = parser .parse_args (sys .argv [1 :])
176182
177183 config_files = args .config_file
Original file line number Diff line number Diff 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)
You can’t perform that action at this time.
0 commit comments