Allow command without shortname.
This commit is contained in:
parent
1ac7390d5e
commit
e0b893708d
1 changed files with 4 additions and 4 deletions
|
|
@ -9,13 +9,13 @@ Callback = Callable[[Args], None]
|
||||||
|
|
||||||
|
|
||||||
class Cmd:
|
class Cmd:
|
||||||
shortName: str
|
shortName: str | None
|
||||||
longName: str
|
longName: str
|
||||||
helpText: str
|
helpText: str
|
||||||
callback: Callable[[Args], None]
|
callback: Callable[[Args], None]
|
||||||
isPlugin: bool = False
|
isPlugin: bool = False
|
||||||
|
|
||||||
def __init__(self, shortName: str, longName: str, helpText: str, callback: Callable[[Args], None]):
|
def __init__(self, shortName: str | None, longName: str, helpText: str, callback: Callable[[Args], None]):
|
||||||
self.shortName = shortName
|
self.shortName = shortName
|
||||||
self.longName = longName
|
self.longName = longName
|
||||||
self.helpText = helpText
|
self.helpText = helpText
|
||||||
|
|
@ -28,7 +28,7 @@ cmds: list[Cmd] = []
|
||||||
def append(cmd: Cmd):
|
def append(cmd: Cmd):
|
||||||
cmd.isPlugin = True
|
cmd.isPlugin = True
|
||||||
cmds.append(cmd)
|
cmds.append(cmd)
|
||||||
cmds.sort(key=lambda c: c.shortName)
|
cmds.sort(key=lambda c: c.shortName or c.longName)
|
||||||
|
|
||||||
|
|
||||||
def runCmd(args: Args):
|
def runCmd(args: Args):
|
||||||
|
|
@ -135,7 +135,7 @@ def helpCmd(args: Args):
|
||||||
pluginText = f"{vt100.CYAN}(plugin){vt100.RESET}"
|
pluginText = f"{vt100.CYAN}(plugin){vt100.RESET}"
|
||||||
|
|
||||||
print(
|
print(
|
||||||
f" {vt100.GREEN}{cmd.shortName}{vt100.RESET} {cmd.longName} - {cmd.helpText} {pluginText}")
|
f" {vt100.GREEN}{cmd.shortName or ' '}{vt100.RESET} {cmd.longName} - {cmd.helpText} {pluginText}")
|
||||||
|
|
||||||
print()
|
print()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue