Skip to content
Snippets Groups Projects
Unverified Commit b6cd0e6c authored by Newbyte's avatar Newbyte :snowflake:
Browse files

pmb.commands: Migrate if ... else chain to match

We no longer care about supporting Python versions older than 3.10,
which is when match was introduced.
parent f53eefa2
No related branches found
No related tags found
No related merge requests found
Pipeline #189214 passed
......@@ -62,27 +62,31 @@ def run_command(args: PmbArgs):
return
command: Command
# Would be nice to use match case but we support Python 3.8
if args.action == "log":
command = Log(args.clear_log, args.lines)
elif args.action == "index":
# FIXME: should index support --arch?
command = Index()
elif args.action == "repo_bootstrap":
command = RepoBootstrap(args.arch, args.repository)
elif args.action == "shutdown":
command = Shutdown()
elif args.action == "test":
command = Test(args.action_test)
elif args.action == "pkgrel_bump":
command = PkgrelBump(args.packages, args.dry, args.auto)
elif args.action == "pull":
command = Pull()
elif args.action == "kconfig" and args.action_kconfig == "check":
command = KConfigCheck(args.kconfig_check_details, args.file, args.package, args.keep_going)
elif args.action == "kconfig" and args.action_kconfig in ["edit", "migrate"]:
command = KConfigEdit(args.package[0], args.action_kconfig == "migrate")
else:
raise NotImplementedError(f"Command '{args.action}' is not implemented.")
match args.action:
case "log":
command = Log(args.clear_log, args.lines)
case "index":
# FIXME: should index support --arch?
command = Index()
case "repo_bootstrap":
command = RepoBootstrap(args.arch, args.repository)
case "shutdown":
command = Shutdown()
case "test":
command = Test(args.action_test)
case "pkgrel_bump":
command = PkgrelBump(args.packages, args.dry, args.auto)
case "pull":
command = Pull()
case "kconfig":
match args.action_kconfig:
case "check":
command = KConfigCheck(
args.kconfig_check_details, args.file, args.package, args.keep_going
)
case "edit" | "migrate":
command = KConfigEdit(args.package[0], args.action_kconfig == "migrate")
case _:
raise NotImplementedError(f"Command '{args.action}' is not implemented.")
command.run()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment