summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorSimon Glass <[email protected]>2025-05-10 13:05:13 +0200
committerSimon Glass <[email protected]>2025-05-27 10:07:43 +0100
commitd6c3f4587889a84f38a90776edaed6e7baa71475 (patch)
tree9e0627b467f8036d65d5ebfad2fba5f461c2739d /tools
parent3f2b3f96e84ac7b65d2dd46296c0732ddcdd86ff (diff)
patman: Support aliases for commands and subcommands
It is laborious to type long commands, so add some aliases to speed up use of patman. For now, allow 'pw' for patchwork and 'st' for status. Signed-off-by: Simon Glass <[email protected]>
Diffstat (limited to 'tools')
-rw-r--r--tools/patman/cmdline.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/tools/patman/cmdline.py b/tools/patman/cmdline.py
index 5943aa7e47c..18434af4cb7 100644
--- a/tools/patman/cmdline.py
+++ b/tools/patman/cmdline.py
@@ -20,6 +20,11 @@ from patman import settings
PATMAN_DIR = pathlib.Path(__file__).parent
HAS_TESTS = os.path.exists(PATMAN_DIR / "func_test.py")
+# Aliases for subcommands
+ALIASES = {
+ 'status': ['st'],
+ 'patchwork': ['pw'],
+ }
class ErrorCatchingArgumentParser(argparse.ArgumentParser):
def __init__(self, **kwargs):
@@ -126,7 +131,7 @@ def add_patchwork_subparser(subparsers):
ArgumentParser: patchwork subparser
"""
patchwork = subparsers.add_parser(
- 'patchwork',
+ 'patchwork', aliases=ALIASES['patchwork'],
help='Manage patchwork connection')
patchwork.defaults_cmds = [
['set-project', 'U-Boot'],
@@ -173,7 +178,7 @@ def add_status_subparser(subparsers):
Return:
ArgumentParser: status subparser
"""
- status = subparsers.add_parser('status',
+ status = subparsers.add_parser('status', aliases=ALIASES['status'],
help='Check status of patches in patchwork')
_add_show_comments(status)
status.add_argument(
@@ -278,4 +283,13 @@ def parse_args(argv=None, config_fname=None, parsers=None):
argv = argv[:-nargs] + ['send'] + rest
args = parser.parse_args(argv)
+ # Resolve aliases
+ for full, aliases in ALIASES.items():
+ if args.cmd in aliases:
+ args.cmd = full
+ if 'subcmd' in args and args.subcmd in aliases:
+ args.subcmd = full
+ if args.cmd in ['series', 'upstream', 'patchwork'] and not args.subcmd:
+ parser.parse_args([args.cmd, '--help'])
+
return args