Expose some shell utilites as commands.
This commit is contained in:
parent
dd4324bad4
commit
16225f50d4
|
@ -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.
|
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">
|
<a href="https://opensource.org/licenses/MIT">
|
||||||
<img align="right" height="96" alt="MIT License" src="doc/mit.svg" />
|
<img align="right" height="96" alt="MIT License" src="doc/mit.svg" />
|
||||||
|
|
|
@ -14,7 +14,7 @@ import dataclasses as dt
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
from . import const
|
from . import const, cli
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
_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}")
|
raise RuntimeError(f"Unknown compression format {format}")
|
||||||
|
|
||||||
return dest
|
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)
|
||||||
|
|
Loading…
Reference in a new issue