Expose some shell utilites as commands.

This commit is contained in:
Sleepy Monax 2024-01-17 17:19:11 +01:00
parent dd4324bad4
commit 16225f50d4
2 changed files with 32 additions and 2 deletions

View file

@ -52,7 +52,7 @@ $ pip install --user -e .
If you want to see how it works you can read the [doc/cutekit.md](doc/cutekit.md) file.
# License
## License
<a href="https://opensource.org/licenses/MIT">
<img align="right" height="96" alt="MIT License" src="doc/mit.svg" />

View file

@ -14,7 +14,7 @@ import dataclasses as dt
from pathlib import Path
from typing import Optional
from . import const
from . import const, cli
_logger = logging.getLogger(__name__)
@ -389,3 +389,33 @@ def compress(path: str, dest: Optional[str] = None, format: str = "zstd") -> str
raise RuntimeError(f"Unknown compression format {format}")
return dest
# --- Commands --------------------------------------------------------------- #
@cli.command("s", "scripts", "Manage scripts")
def _(args: cli.Args):
pass
@cli.command("d", "debug", "Debug a program")
def _(args: cli.Args):
wait = args.consumeOpt("wait", False) is True
debugger = args.consumeOpt("debugger", "lldb")
command = [str(args.consumeArg()), *args.extra]
debug(command, debugger=debugger, wait=wait)
@cli.command("p", "profile", "Profile a program")
def _(args: cli.Args):
command = [str(args.consumeArg()), *args.extra]
profile(command)
@cli.command("c", "compress", "Compress a file or directory")
def _(args: cli.Args):
path = str(args.consumeArg())
dest = args.consumeOpt("dest", None)
format = args.consumeOpt("format", "zstd")
compress(path, dest, format)