replaced click
This commit is contained in:
@@ -52,7 +52,6 @@ jobs:
|
|||||||
python3 -m venv .venv
|
python3 -m venv .venv
|
||||||
. .venv/bin/activate
|
. .venv/bin/activate
|
||||||
pip install --no-cache-dir \
|
pip install --no-cache-dir \
|
||||||
click \
|
|
||||||
typer \
|
typer \
|
||||||
pillow \
|
pillow \
|
||||||
materialyoucolor \
|
materialyoucolor \
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ name = "zshell"
|
|||||||
requires-python = ">=3.13"
|
requires-python = ">=3.13"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"click",
|
|
||||||
"typer",
|
"typer",
|
||||||
"pillow",
|
"pillow",
|
||||||
"jinja2",
|
"jinja2",
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ from __future__ import annotations
|
|||||||
import sys
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import click
|
|
||||||
import typer
|
import typer
|
||||||
from typer._completion_shared import install, _get_shell_name
|
from typer._completion_shared import install, _get_shell_name
|
||||||
from zshell.subcommands import shell, scheme, screenshot, wallpaper, record
|
from zshell.subcommands import shell, scheme, screenshot, wallpaper, record
|
||||||
@@ -30,16 +29,16 @@ def _completion_installed() -> bool:
|
|||||||
|
|
||||||
def _install_completion() -> None:
|
def _install_completion() -> None:
|
||||||
if _completion_installed():
|
if _completion_installed():
|
||||||
click.echo("zshell-cli: Shell completion already installed.")
|
print("zshell-cli: Shell completion already installed.")
|
||||||
raise typer.Exit()
|
raise typer.Exit()
|
||||||
shell = _get_shell_name()
|
shell = _get_shell_name()
|
||||||
if shell is None:
|
if shell is None:
|
||||||
click.echo("zshell-cli: Unable to detect shell type.", err=True)
|
print("zshell-cli: Unable to detect shell type.", file=sys.stderr)
|
||||||
raise typer.Exit(code=1)
|
raise typer.Exit(code=1)
|
||||||
try:
|
try:
|
||||||
_, path = install(prog_name="zshell-cli")
|
_, path = install(prog_name="zshell-cli")
|
||||||
click.secho(f"zshell-cli: Shell completion installed ({shell}: {path})", fg="green")
|
print(f"zshell-cli: Shell completion installed ({shell}: {path})")
|
||||||
click.echo("zshell-cli: Restart your shell or source the file to enable tab-completion.")
|
print("zshell-cli: Restart your shell or source the file to enable tab-completion.")
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@@ -49,5 +48,5 @@ def main() -> None:
|
|||||||
_install_completion()
|
_install_completion()
|
||||||
return
|
return
|
||||||
if sys.stdout.isatty() and not _completion_installed():
|
if sys.stdout.isatty() and not _completion_installed():
|
||||||
click.echo("zshell-cli: Tip: run with --install-autocomplete for tab completion.", err=True)
|
print("zshell-cli: Tip: run with --install-autocomplete for tab completion.", file=sys.stderr)
|
||||||
app()
|
app()
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import subprocess
|
|||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import click
|
|
||||||
import typer
|
import typer
|
||||||
|
|
||||||
args = ["qs", "-c", "zshell"]
|
args = ["qs", "-c", "zshell"]
|
||||||
@@ -14,7 +13,8 @@ app = typer.Typer()
|
|||||||
def kill():
|
def kill():
|
||||||
result = subprocess.run(args + ["kill"], capture_output=True)
|
result = subprocess.run(args + ["kill"], capture_output=True)
|
||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
raise click.ClickException("No running instance to kill.")
|
sys.stderr.write("No running instance to kill.\n")
|
||||||
|
sys.exit(1)
|
||||||
sys.stderr.write(result.stderr.decode())
|
sys.stderr.write(result.stderr.decode())
|
||||||
|
|
||||||
|
|
||||||
@@ -23,10 +23,12 @@ def start_instance(no_daemon: bool = False) -> None:
|
|||||||
stdout = result.stdout.decode().strip()
|
stdout = result.stdout.decode().strip()
|
||||||
if stdout:
|
if stdout:
|
||||||
if "already running" in stdout.lower():
|
if "already running" in stdout.lower():
|
||||||
raise click.ClickException(stdout)
|
sys.stderr.write(stdout + "\n")
|
||||||
|
sys.exit(1)
|
||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
stderr = result.stderr.decode().strip()
|
stderr = result.stderr.decode().strip()
|
||||||
raise click.ClickException(stderr)
|
sys.stderr.write(stderr + "\n")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
@app.command()
|
@app.command()
|
||||||
@@ -50,7 +52,8 @@ def restart(no_daemon: bool = False):
|
|||||||
def show():
|
def show():
|
||||||
result = subprocess.run(args + ["ipc"] + ["show"], capture_output=True)
|
result = subprocess.run(args + ["ipc"] + ["show"], capture_output=True)
|
||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
raise click.ClickException(result.stderr.decode().strip())
|
sys.stderr.write(result.stderr.decode())
|
||||||
|
sys.exit(1)
|
||||||
sys.stdout.write(result.stdout.decode())
|
sys.stdout.write(result.stdout.decode())
|
||||||
sys.stderr.write(result.stderr.decode())
|
sys.stderr.write(result.stderr.decode())
|
||||||
|
|
||||||
@@ -59,7 +62,8 @@ def show():
|
|||||||
def log():
|
def log():
|
||||||
result = subprocess.run(args + ["log"], capture_output=True)
|
result = subprocess.run(args + ["log"], capture_output=True)
|
||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
raise click.ClickException(result.stderr.decode().strip())
|
sys.stderr.write(result.stderr.decode())
|
||||||
|
sys.exit(1)
|
||||||
sys.stdout.write(result.stdout.decode())
|
sys.stdout.write(result.stdout.decode())
|
||||||
sys.stderr.write(result.stderr.decode())
|
sys.stderr.write(result.stderr.decode())
|
||||||
|
|
||||||
@@ -68,7 +72,8 @@ def log():
|
|||||||
def lock():
|
def lock():
|
||||||
result = subprocess.run(args + ["ipc"] + ["call"] + ["lock"] + ["lock"], capture_output=True)
|
result = subprocess.run(args + ["ipc"] + ["call"] + ["lock"] + ["lock"], capture_output=True)
|
||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
raise click.ClickException(result.stderr.decode().strip())
|
sys.stderr.write(result.stderr.decode())
|
||||||
|
sys.exit(1)
|
||||||
sys.stderr.write(result.stderr.decode())
|
sys.stderr.write(result.stderr.decode())
|
||||||
|
|
||||||
|
|
||||||
@@ -76,5 +81,6 @@ def lock():
|
|||||||
def call(target: str, method: str, method_args: list[str] = typer.Argument(None)):
|
def call(target: str, method: str, method_args: list[str] = typer.Argument(None)):
|
||||||
result = subprocess.run(args + ["ipc"] + ["call"] + [target] + [method] + (method_args or []), capture_output=True)
|
result = subprocess.run(args + ["ipc"] + ["call"] + [target] + [method] + (method_args or []), capture_output=True)
|
||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
raise click.ClickException(result.stderr.decode().strip())
|
sys.stderr.write(result.stderr.decode())
|
||||||
|
sys.exit(1)
|
||||||
sys.stderr.write(result.stderr.decode())
|
sys.stderr.write(result.stderr.decode())
|
||||||
|
|||||||
Reference in New Issue
Block a user