From fda3712855c905706e565e86daded355c80beb5c Mon Sep 17 00:00:00 2001 From: AramJonghu Date: Thu, 28 May 2026 13:49:34 +0200 Subject: [PATCH 1/4] attempt hotfix --- cli/src/zshell/__init__.py | 7 +++++-- cli/src/zshell/subcommands/scheme.py | 6 +++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/cli/src/zshell/__init__.py b/cli/src/zshell/__init__.py index 023f0ae..04e5ad7 100644 --- a/cli/src/zshell/__init__.py +++ b/cli/src/zshell/__init__.py @@ -4,6 +4,7 @@ from pathlib import Path import typer from typer._completion_shared import install, _get_shell_name +from typer._completion_classes import completion_init from zshell.subcommands import shell, scheme, screenshot, wallpaper, record app = typer.Typer(name="zshell-cli", add_completion=False) @@ -39,14 +40,16 @@ def _install_completion() -> None: _, path = install(prog_name="zshell-cli") print(f"zshell-cli: Shell completion installed ({shell}: {path})") print("zshell-cli: Restart your shell or source the file to enable tab-completion.") - except Exception: - pass + except Exception as e: + print(f"zshell-cli: Failed to install shell completion: {e}", file=sys.stderr) + raise typer.Exit(code=1) def main() -> None: if "--install-autocomplete" in sys.argv: _install_completion() return + completion_init() if sys.stdout.isatty() and not _completion_installed(): print("zshell-cli: Tip: run with --install-autocomplete for tab completion.", file=sys.stderr) app() diff --git a/cli/src/zshell/subcommands/scheme.py b/cli/src/zshell/subcommands/scheme.py index 8cb1feb..9a1caa1 100644 --- a/cli/src/zshell/subcommands/scheme.py +++ b/cli/src/zshell/subcommands/scheme.py @@ -25,7 +25,7 @@ from materialyoucolor.utils.math_utils import ( app = typer.Typer() -def _complete_scheme_name(incomplete): +def _complete_scheme_name(ctx, incomplete): schemes = [ "fruit-salad", "expressive", @@ -40,7 +40,7 @@ def _complete_scheme_name(incomplete): return [s for s in schemes if incomplete in s] -def _complete_preset(incomplete): +def _complete_preset(ctx, incomplete): results = [] for sid, meta in list_schemes().items(): for v in meta.variants: @@ -50,7 +50,7 @@ def _complete_preset(incomplete): return results -def _complete_mode(incomplete): +def _complete_mode(ctx, incomplete): return [m for m in ("dark", "light") if incomplete in m] From 0ad28ac01785c50cdb1c1b77fc6afd5fe8becaa6 Mon Sep 17 00:00:00 2001 From: AramJonghu Date: Thu, 28 May 2026 14:08:02 +0200 Subject: [PATCH 2/4] now a check if cli completion is installed --- cli/src/zshell/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cli/src/zshell/__init__.py b/cli/src/zshell/__init__.py index 04e5ad7..2302eed 100644 --- a/cli/src/zshell/__init__.py +++ b/cli/src/zshell/__init__.py @@ -1,4 +1,5 @@ from __future__ import annotations +import os import sys from pathlib import Path @@ -49,7 +50,8 @@ def main() -> None: if "--install-autocomplete" in sys.argv: _install_completion() return - completion_init() + if "_ZSHELL_CLI_COMPLETE" in os.environ: + completion_init() if sys.stdout.isatty() and not _completion_installed(): print("zshell-cli: Tip: run with --install-autocomplete for tab completion.", file=sys.stderr) app() From e9aa8268bedf785a1b9c31ff23b88c2a79de9ff1 Mon Sep 17 00:00:00 2001 From: AramJonghu Date: Thu, 28 May 2026 14:25:43 +0200 Subject: [PATCH 3/4] ctx is unused --- cli/src/zshell/subcommands/scheme.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cli/src/zshell/subcommands/scheme.py b/cli/src/zshell/subcommands/scheme.py index 9a1caa1..8cb1feb 100644 --- a/cli/src/zshell/subcommands/scheme.py +++ b/cli/src/zshell/subcommands/scheme.py @@ -25,7 +25,7 @@ from materialyoucolor.utils.math_utils import ( app = typer.Typer() -def _complete_scheme_name(ctx, incomplete): +def _complete_scheme_name(incomplete): schemes = [ "fruit-salad", "expressive", @@ -40,7 +40,7 @@ def _complete_scheme_name(ctx, incomplete): return [s for s in schemes if incomplete in s] -def _complete_preset(ctx, incomplete): +def _complete_preset(incomplete): results = [] for sid, meta in list_schemes().items(): for v in meta.variants: @@ -50,7 +50,7 @@ def _complete_preset(ctx, incomplete): return results -def _complete_mode(ctx, incomplete): +def _complete_mode(incomplete): return [m for m in ("dark", "light") if incomplete in m] From 52be099914811693a35e7f315aaff9c9881a98cb Mon Sep 17 00:00:00 2001 From: AramJonghu Date: Thu, 28 May 2026 22:43:25 +0200 Subject: [PATCH 4/4] removed exception in favor of sys.exit() to exit silently with print --- cli/src/zshell/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/src/zshell/__init__.py b/cli/src/zshell/__init__.py index 2302eed..9c8c6b8 100644 --- a/cli/src/zshell/__init__.py +++ b/cli/src/zshell/__init__.py @@ -32,11 +32,11 @@ def _completion_installed() -> bool: def _install_completion() -> None: if _completion_installed(): print("zshell-cli: Shell completion already installed.") - raise typer.Exit() + sys.exit(0) shell = _get_shell_name() if shell is None: print("zshell-cli: Unable to detect shell type.", file=sys.stderr) - raise typer.Exit(code=1) + sys.exit(1) try: _, path = install(prog_name="zshell-cli") print(f"zshell-cli: Shell completion installed ({shell}: {path})")