Compare commits

..

2 commits

Author SHA1 Message Date
5607588c88
cmds.CmdPkg: Rename pkg -> packages
Some checks failed
CI / Packaging - Kali Linux (pull_request) Failing after 2m19s
CI / Packaging - OpenSUSE Tumbleweed (pull_request) Failing after 2m30s
CI / Packaging test (pull_request) Failing after 0s

Relabel the toplevel command CmdPkg from "pkg" to "packages", because it rolls off the tounge much more nicely. Keep "pkg" as an alias for compatibilty.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-06-25 09:35:39 +02:00
effda76f33
lib.Cmd.AbstractCmd.aliases: Add property

Add a property aliases to AbstractCmd in prepeparation for commands to bear multiple names / abbreviations / aliases.

The App.add_cmds_to_parser() function uses parse_known_args() to determine which subcommand was invoked, then conditionally registers nested subcommands. The lookup dictionary (scs) contains only canonical names, not aliases, so add them too, otherwise using the alias instead of the canonical name causes the lookup to fail and nested subcommands to never be registered.

Fix: Register each alias in scs pointing to the same SubCommand object, and deduplicate with id(sc) when iterating in all=True mode to avoid infinite recursion on help output.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-06-25 09:34:13 +02:00
2 changed files with 9 additions and 10 deletions

View file

@ -83,15 +83,12 @@ cmd_create_init()
done done
fi fi
if [ ${#seen[@]} -eq 0 ]; then echo
echo "__all__ = []"
else
echo "__all__ = [" echo "__all__ = ["
for dst_type in ${!seen[@]}; do for dst_type in ${!seen[@]}; do
echo " \"$dst_type\"," echo " \"$dst_type\","
done done
echo "]" echo "]"
fi
echo "# << $del <<" echo "# << $del <<"
} }

View file

@ -104,7 +104,9 @@ class App: # export
cmd_name = getattr(args, 'command', None) cmd_name = getattr(args, 'command', None)
if cmd_name in scs: if cmd_name in scs:
sc = scs[cmd_name] sc = scs[cmd_name]
add_cmds_to_parser(sc.cmd, sc.parser, sc.cmd.children, all = all) add_cmds_to_parser(
sc.cmd, sc.parser, sc.cmd.children, all = all
)
from .Cmd import AbstractCmd from .Cmd import AbstractCmd