Skip to content

Commit f36c1c0

Browse files
glehmannydirson
authored andcommitted
Add completion support
Signed-off-by: Gaëtan Lehmann <gaetan.lehmann@vates.tech>
1 parent 9892cab commit f36c1c0

File tree

4 files changed

+43
-0
lines changed

4 files changed

+43
-0
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,20 @@ like `pipx install --editable .`
5454
If you do not want this behaviour, use: `uv tool install --from . xcp-ng-dev`
5555
or `pipx install .`
5656

57+
## Completion
58+
59+
### Bash
60+
61+
To install the completion, add `eval "$(register-python-argcomplete xcp-ng-dev)"` to `~/.bash_completion` and relaunch Bash.
62+
63+
### Zsh
64+
65+
To install the completion, add `eval "$(register-python-argcomplete xcp-ng-dev)"` to `~/.zshrc` and relaunch Zsh.
66+
67+
### Fish
68+
69+
To install the completion, run `register-python-argcomplete --shell fish xcp-ng-dev > ~/.config/fish/completions/xcp-ng-dev.fish` and relaunch fish.
70+
5771
## Building the container image(s)
5872

5973
You need one container image per target version of XCP-ng.

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ requires-python = ">=3.11"
66
license = "MIT"
77
license-files = ["LICENSE"]
88
dynamic = ["version"]
9+
dependencies = [
10+
"argcomplete",
11+
]
912

1013
[project.scripts]
1114
xcp-ng-dev = "xcp_ng_dev.cli:main"

src/xcp_ng_dev/cli.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
3+
# PYTHON_ARGCOMPLETE_OK
34

45
"""
56
Thin wrapper around "docker run" or "podman run".
@@ -13,6 +14,7 @@
1314
import shutil
1415
import sys
1516
import uuid
17+
import argcomplete
1618

1719
CONTAINER_PREFIX = "ghcr.io/xcp-ng/xcp-ng-build-env"
1820

@@ -221,6 +223,8 @@ def main():
221223
""" Main entry point. """
222224
parser = buildparser()
223225

226+
argcomplete.autocomplete(parser)
227+
224228
args = parser.parse_args()
225229

226230
return_code = args.func(args)

uv.lock

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)