commands: new submodule (MR 2252)

The current mechanism of invoking pmbootstrap actions can be a bit
confusing, and relies heavily on args being a big namespace with lots of
properties (which may or may not be valid depending on the context).

To aid in slowly removing args from the codebase, introduce a new
mechanism for running commands. This works by having a class for each
command, where the arguments are passed in as parameters to the
constructor.

No doubt this won't scale very far, but it's a skeleton we can continue
to build on as we migrate more commands over to not require args in
order to run.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
This commit is contained in:
Caleb Connolly 2024-05-24 18:46:21 +02:00 committed by Oliver Smith
parent 52cf0e0fe3
commit 8526631589
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
6 changed files with 121 additions and 25 deletions

9
pmb/commands/base.py Normal file
View file

@ -0,0 +1,9 @@
# Copyright 2024 Caleb Connolly
# SPDX-License-Identifier: GPL-3.0-or-later
class Command():
"""Base class for pmbootstrap commands."""
def run(self):
"""Run the command."""
raise NotImplementedError()