Fix argv0
This commit is contained in:
parent
886c90dd6f
commit
f783f5607c
4 changed files with 20 additions and 9 deletions
|
@ -76,7 +76,7 @@ def _(args: RootArgs):
|
||||||
|
|
||||||
@cli.command("u", "usage", "Show usage information")
|
@cli.command("u", "usage", "Show usage information")
|
||||||
def _():
|
def _():
|
||||||
print(f"Usage: {const.ARGV0} <command> [args...]")
|
print(f"Usage: {const.ARGV0} {cli._root.usage()}")
|
||||||
|
|
||||||
|
|
||||||
@cli.command("v", "version", "Show current version")
|
@cli.command("v", "version", "Show current version")
|
||||||
|
|
|
@ -4,7 +4,7 @@ import typing as tp
|
||||||
import dataclasses as dt
|
import dataclasses as dt
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from typing import Any, Callable, Optional, Union
|
from typing import Any, Callable, Optional
|
||||||
from cutekit import vt100, const
|
from cutekit import vt100, const
|
||||||
|
|
||||||
|
|
||||||
|
@ -536,7 +536,7 @@ class Schema:
|
||||||
@dt.dataclass
|
@dt.dataclass
|
||||||
class Command:
|
class Command:
|
||||||
shortName: Optional[str]
|
shortName: Optional[str]
|
||||||
longName: str
|
path: list[str] = dt.field(default_factory=list)
|
||||||
description: str = ""
|
description: str = ""
|
||||||
epilog: Optional[str] = None
|
epilog: Optional[str] = None
|
||||||
|
|
||||||
|
@ -544,7 +544,10 @@ class Command:
|
||||||
callable: Optional[tp.Callable] = None
|
callable: Optional[tp.Callable] = None
|
||||||
subcommands: dict[str, "Command"] = dt.field(default_factory=dict)
|
subcommands: dict[str, "Command"] = dt.field(default_factory=dict)
|
||||||
populated: bool = False
|
populated: bool = False
|
||||||
path: list[str] = dt.field(default_factory=list)
|
|
||||||
|
@property
|
||||||
|
def longName(self) -> str:
|
||||||
|
return self.path[-1]
|
||||||
|
|
||||||
def _spliceArgs(self, args: list[str]) -> tuple[list[str], list[str]]:
|
def _spliceArgs(self, args: list[str]) -> tuple[list[str], list[str]]:
|
||||||
rest = args[:]
|
rest = args[:]
|
||||||
|
@ -601,9 +604,6 @@ class Command:
|
||||||
print(self.epilog)
|
print(self.epilog)
|
||||||
print()
|
print()
|
||||||
|
|
||||||
# for name, sub in self.subcommands.items():
|
|
||||||
# sub.help(f"{cmd} {name}")
|
|
||||||
|
|
||||||
def usage(self) -> str:
|
def usage(self) -> str:
|
||||||
res = " "
|
res = " "
|
||||||
if self.schema:
|
if self.schema:
|
||||||
|
@ -716,7 +716,6 @@ def command(shortName: Optional[str], longName: str, description: str = "") -> C
|
||||||
raise ValueError(f"Command '{longName}' is already defined")
|
raise ValueError(f"Command '{longName}' is already defined")
|
||||||
|
|
||||||
cmd.shortName = shortName
|
cmd.shortName = shortName
|
||||||
cmd.longName = len(path) > 0 and path[-1] or ""
|
|
||||||
cmd.description = description
|
cmd.description = description
|
||||||
cmd.schema = schema
|
cmd.schema = schema
|
||||||
cmd.callable = fn
|
cmd.callable = fn
|
||||||
|
|
|
@ -18,7 +18,9 @@ class Uninitialized:
|
||||||
VERSION = (0, 7, 0, "dev")
|
VERSION = (0, 7, 0, "dev")
|
||||||
VERSION_STR = f"{VERSION[0]}.{VERSION[1]}.{VERSION[2]}{'-' + VERSION[3] if len(VERSION) >= 4 else ''}"
|
VERSION_STR = f"{VERSION[0]}.{VERSION[1]}.{VERSION[2]}{'-' + VERSION[3] if len(VERSION) >= 4 else ''}"
|
||||||
MODULE_DIR = os.path.dirname(os.path.realpath(__file__))
|
MODULE_DIR = os.path.dirname(os.path.realpath(__file__))
|
||||||
ARGV0 = os.path.basename(sys.argv[0])
|
|
||||||
|
|
||||||
|
ARGV0 = "cutekit"
|
||||||
PROJECT_CK_DIR = ".cutekit"
|
PROJECT_CK_DIR = ".cutekit"
|
||||||
GLOBAL_CK_DIR = os.path.join(os.path.expanduser("~"), ".cutekit")
|
GLOBAL_CK_DIR = os.path.join(os.path.expanduser("~"), ".cutekit")
|
||||||
BUILD_DIR = os.path.join(PROJECT_CK_DIR, "build")
|
BUILD_DIR = os.path.join(PROJECT_CK_DIR, "build")
|
||||||
|
|
|
@ -237,6 +237,8 @@ def _(args: PodKillArgs):
|
||||||
def _():
|
def _():
|
||||||
client = docker.from_env()
|
client = docker.from_env()
|
||||||
hasPods = False
|
hasPods = False
|
||||||
|
|
||||||
|
vt100.subtitle("Pods")
|
||||||
for container in client.containers.list(all=True):
|
for container in client.containers.list(all=True):
|
||||||
if not container.name.startswith(podPrefix):
|
if not container.name.startswith(podPrefix):
|
||||||
continue
|
continue
|
||||||
|
@ -246,6 +248,14 @@ def _():
|
||||||
if not hasPods:
|
if not hasPods:
|
||||||
print(vt100.p("(No pod found)"))
|
print(vt100.p("(No pod found)"))
|
||||||
|
|
||||||
|
print()
|
||||||
|
|
||||||
|
vt100.subtitle("Images")
|
||||||
|
for name, image in IMAGES.items():
|
||||||
|
print(vt100.p(f"{name}"))
|
||||||
|
|
||||||
|
print()
|
||||||
|
|
||||||
|
|
||||||
@cli.command("e", "pod/exec", "Execute a command in a pod")
|
@cli.command("e", "pod/exec", "Execute a command in a pod")
|
||||||
def podExecCmd(args: PodExecArgs):
|
def podExecCmd(args: PodExecArgs):
|
||||||
|
|
Loading…
Reference in a new issue