From 78f45009c3eb55faad0d7926a17cbea6c2d1f7a2 Mon Sep 17 00:00:00 2001 From: Jonas Blixt Date: Mon, 4 Dec 2023 20:04:00 +0100 Subject: [PATCH] tools: punchboot: Add shell completion help command --- tools/punchboot/punchboot/__main__.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tools/punchboot/punchboot/__main__.py b/tools/punchboot/punchboot/__main__.py index ad673d67..ce1f9085 100644 --- a/tools/punchboot/punchboot/__main__.py +++ b/tools/punchboot/punchboot/__main__.py @@ -631,5 +631,27 @@ def slc_revoke_key(ctx: click.Context, s: Session, key_id: str, force: bool): s.slc_revoke_key(_key_id) +@cli.command("completion") +@click.pass_context +def shell_completion_helper(ctx: click.Context): + """Shell completion helpers.""" + _help_text = """ + Punchboot supports shell completions for bash, zsh and fish. + Put one of the following lines in the appropriate .rc -file to enable + shell completions. + + bash: + eval "$(_PUNCHBOOT_COMPLETE=bash_source punchboot)" + + zsh: + eval "$(_PUNCHBOOT_COMPLETE=zsh_source punchboot)" + + fish: + _PUNCHBOOT_COMPLETE=fish_source punchboot | source + """ + + click.echo(_help_text) + + if __name__ == "__main__": cli()