diff --git a/README.md b/README.md index aa759a2..94a5fbe 100644 --- a/README.md +++ b/README.md @@ -32,11 +32,12 @@ It is highly recommended to setup a dedicated user for the tool usage. You shoul If you plan to use `pvecontrol` in read only mode to fetch cluster informations you can limit user with only `PVEAuditor` on Path `/` Permissions. This is the minimum permissions needed by `pvecontrol` to work. For other operations on VMs it is recommended to grant `PVEVMAdmin` on Path `/`. This allows start, stop, migrate, ... -Once you have setup your management user for `pvecontrol` you can generate your configuration file. Default configuration template with all options is available (here)[https://github.com/enix/pvecontrol/blob/dev/src/pvecontrol/config_default.yaml]. +Once you have setup your management user for `pvecontrol` you can generate your configuration file. Default configuration template with all options is available [here](https://github.com/enix/pvecontrol/blob/dev/src/pvecontrol/config_default.yaml). You can use shell commands on cluster fields user and password like `user: $()` this allow you to user external software to get your secrets. Use this file to build your own configuration file or the above exemple: + ```yaml --- @@ -128,6 +129,18 @@ INFO:root:Proxmox cluster: my-test-cluster If this works, you're ready to go +Shell Auto Completion +--- + +`pvecontrol` provide an auto completion helper to automatically generate configuration for your prefered shell. It support curently `bash`,`zsh` and `tcsh`. The following exemple must be adapted to your own environment: + +```shell +# bash +$ pvecontrol --print-completion bash > "${BASH_COMPLETION_USER_DIR:-${XDG_DATA_HOME:-$HOME/.local/share}/bash-completion}/completions/pvecontrol" +# zsh +$ pvecontrol --print-completion zsh > "${HOME}/.zsh/completions/_pvecontrol" +``` + Development --- diff --git a/requirements.txt b/requirements.txt index 986a483..38313e5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,11 +1,13 @@ - prettytable - humanize - confuse - pyyaml - urllib3 -# proxmoxer depdends - proxmoxer>=2.0.1 - requests - requests_toolbelt - openssh_wrapper - paramiko +prettytable +humanize +confuse +pyyaml +urllib3 +shtab + +# proxmoxer depdends +proxmoxer>=2.0.1 +requests +requests_toolbelt +openssh_wrapper +paramiko diff --git a/src/pvecontrol/__init__.py b/src/pvecontrol/__init__.py index e101edb..9cb7b0e 100644 --- a/src/pvecontrol/__init__.py +++ b/src/pvecontrol/__init__.py @@ -6,6 +6,7 @@ import re import subprocess import urllib3 +import shtab from pvecontrol import actions, node, vm, task, storage from pvecontrol.cluster import PVECluster @@ -147,6 +148,9 @@ def _parser(): parser_test = subparsers.add_parser("_test") parser_test.set_defaults(func=action_test) + # shell autocomplete generation + shtab.add_argument_to(parser, ["-s", "--print-completion"]) + return parser.parse_args()