7 Commits

Author SHA1 Message Date
zach 84ecd1481b Merge branch 'main' into zshell-img-tools
Lint & Format (JS/TS) / lint-format (pull_request) Successful in 11s
Python / lint-format (pull_request) Successful in 25s
Python / test (pull_request) Successful in 50s
Lint & Format (Rust) / lint-format (pull_request) Successful in 1m8s
2026-05-28 23:24:26 +02:00
zach 428809fee8 Merge pull request 'hotfix zshell-cli autocompletion failing' (#108) from hotfix-zshell-autocompletion into main
Reviewed-on: #108
Reviewed-by: zach <zach@brohn.se>
2026-05-28 23:24:17 +02:00
AramJonghu 52be099914 removed exception in favor of sys.exit() to exit silently with print
Lint & Format (JS/TS) / lint-format (pull_request) Successful in 12s
Python / lint-format (pull_request) Successful in 20s
Python / test (pull_request) Successful in 44s
Lint & Format (Rust) / lint-format (pull_request) Successful in 1m46s
2026-05-28 22:43:25 +02:00
zach 494653e029 Merge branch 'main' into hotfix-zshell-autocompletion
Lint & Format (JS/TS) / lint-format (pull_request) Successful in 11s
Python / lint-format (pull_request) Successful in 18s
Python / test (pull_request) Successful in 1m20s
Lint & Format (Rust) / lint-format (pull_request) Successful in 1m57s
2026-05-28 16:55:42 +02:00
AramJonghu e9aa8268be ctx is unused
Lint & Format (JS/TS) / lint-format (pull_request) Successful in 13s
Python / lint-format (pull_request) Successful in 19s
Python / test (pull_request) Successful in 47s
Lint & Format (Rust) / lint-format (pull_request) Successful in 1m46s
2026-05-28 14:25:43 +02:00
AramJonghu 0ad28ac017 now a check if cli completion is installed 2026-05-28 14:08:02 +02:00
AramJonghu fda3712855 attempt hotfix 2026-05-28 13:49:34 +02:00
+9 -4
View File
@@ -1,9 +1,11 @@
from __future__ import annotations
import os
import sys
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)
@@ -30,23 +32,26 @@ 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})")
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
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()