cmds.project.*: Make _run() async

Cmd._run(), as conceived for working with lib.App, is meant to be an
async method. To be conservative about changes, jw-pkg's legacy way
of handling _run() was kept when deriving from libApp, and async was
not propagated down to the _run() implementations. This commit
rectifies that before adding additional subcommands.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-01-27 14:31:25 +01:00
commit 9c06103a4a
27 changed files with 27 additions and 27 deletions

View file

@ -22,4 +22,4 @@ class Cmd(Base): # export
)
async def run(self, args):
return self._run(args)
return await self._run(args)

View file

@ -15,5 +15,5 @@ class CmdProjects(CmdBase): # export
def add_arguments(self, p: ArgumentParser) -> None:
super().add_arguments(p)
def _run(self, args):
async def _run(self, args):
raise Exception("Running with args", args)

View file

@ -100,5 +100,5 @@ class BaseCmdPkgRelations(Cmd):
parser.add_argument('--ignore', nargs='?', default='', help='Packages that '
'should be ignored together with their dependencies')
def _run(self, args: Namespace) -> None:
async def _run(self, args: Namespace) -> None:
return self.print_pkg_relations(self.relation, args)

View file

@ -26,7 +26,7 @@ class CmdBuild(Cmd): # export
parser.add_argument('target', default='all', help='Build target')
parser.add_argument('modules', nargs='+', default='', help='Modules to be built')
def _run(self, args: Namespace) -> None:
async def _run(self, args: Namespace) -> None:
@lru_cache(maxsize=None)
def read_deps(cur, prereq_type):

View file

@ -15,7 +15,7 @@ class CmdCflags(Cmd): # export
super().add_arguments(parser)
parser.add_argument('module', nargs='*', help='Modules')
def _run(self, args: Namespace) -> None:
async def _run(self, args: Namespace) -> None:
deps = self.app.get_modules_from_project_txt(args.module, ['pkg.requires.jw'], 'build',
scope = Scope.Subtree, add_self=True, names_only=True)
out = []

View file

@ -16,7 +16,7 @@ class CmdCheck(Cmd): # export
parser.add_argument('module', nargs='*', help='Modules')
parser.add_argument('-f', '--flavour', nargs='?', default = 'build')
def _run(self, args: Namespace) -> None:
async def _run(self, args: Namespace) -> None:
graph = {}
path = []
self.app.read_dep_graph(args.module, args.flavour, graph)

View file

@ -13,7 +13,7 @@ class CmdCommands(Cmd): # export
def add_arguments(self, parser: ArgumentParser) -> None:
super().add_arguments(parser)
def _run(self, args: Namespace) -> None:
async def _run(self, args: Namespace) -> None:
import sys, re, os, glob
this_dir = os.path.dirname(sys.modules[__name__].__file__)
ret = []

View file

@ -25,7 +25,7 @@ class CmdCreatePkgConfig(Cmd): # export
parser.add_argument('-R', '--requires_build', default=None)
parser.add_argument('-V', '--variables', nargs='*')
def _run(self, args: Namespace) -> None:
async def _run(self, args: Namespace) -> None:
project_conf_var_keys = ['description', 'summary', 'requires_run', 'requires_build']
merged: dict[str, str] = {}
for key in project_conf_var_keys:

View file

@ -15,7 +15,7 @@ class CmdExepath(Cmd): # export
super().add_arguments(parser)
parser.add_argument('module', nargs='*', help='Modules')
def _run(self, args: Namespace) -> None:
async def _run(self, args: Namespace) -> None:
deps = self.app.get_modules_from_project_txt(args.module, ['pkg.requires.jw'], [ 'run', 'build', 'devel' ],
scope = Scope.Subtree, add_self=True, names_only=True)
out = []

View file

@ -21,7 +21,7 @@ class CmdGetAuthInfo(Cmd): # export
parser.add_argument('--password', help='Show password', action='store_true', default=False)
parser.add_argument('--remote-base', help='Show remote base URL', action='store_true', default=False)
def _run(self, args: Namespace) -> None:
async def _run(self, args: Namespace) -> None:
keys = ['username', 'password']
# --- Milk jw-pkg repo

View file

@ -16,7 +16,7 @@ class CmdGetval(Cmd): # export
parser.add_argument('section', default = '', help = 'Config section')
parser.add_argument('key', default = '', help = 'Config key')
def _run(self, args: Namespace) -> None:
async def _run(self, args: Namespace) -> None:
project = args.project
if project is None:
args.project = self.app.top_name

View file

@ -14,7 +14,7 @@ class CmdHtdocsDir(Cmd): # export
super().add_arguments(parser)
parser.add_argument('module', nargs='*', help='Modules')
def _run(self, args: Namespace) -> None:
async def _run(self, args: Namespace) -> None:
r = []
for m in args.module:
r.append(self.app.htdocs_dir(m))

View file

@ -37,7 +37,7 @@ class CmdLdflags(Cmd): # export
return None
return(' '.join(ret))
def _run(self, args: Namespace) -> None:
async def _run(self, args: Namespace) -> None:
deps = self.app.get_modules_from_project_txt(args.module, ['pkg.requires.jw'], 'build',
scope = Scope.One, add_self=args.add_self, names_only=True)
out = []

View file

@ -15,7 +15,7 @@ class CmdLdlibpath(Cmd): # export
super().add_arguments(parser)
parser.add_argument('module', nargs='*', help='Modules')
def _run(self, args: Namespace) -> None:
async def _run(self, args: Namespace) -> None:
deps = self.app.get_modules_from_project_txt(args.module, ['pkg.requires.jw'], [ 'run', 'build', 'devel' ],
scope = Scope.Subtree, add_self=True, names_only=True)
out = []

View file

@ -14,5 +14,5 @@ class CmdLibname(Cmd): # export
super().add_arguments(parser)
parser.add_argument('module', nargs='*', help='Modules')
def _run(self, args: Namespace) -> None:
async def _run(self, args: Namespace) -> None:
print(self.app.get_libname(args.module))

View file

@ -20,7 +20,7 @@ class CmdListRepos(Cmd): # export
parser.add_argument('--askpass', help='Program to echo password for SSH or HTTP authentication, don\'t specify for unauthenticated', default=None)
parser.add_argument('--from-user', help='List from-user\'s projects', default='janware')
def _run(self, args: Namespace) -> None:
async def _run(self, args: Namespace) -> None:
from urllib.parse import urlparse
url = urlparse(args.base_url)

View file

@ -15,7 +15,7 @@ class CmdModules(Cmd): # export
super().add_arguments(parser)
parser.add_argument('-F', '--filter', nargs='?', default=None, help='Key-value pairs, seperated by commas, to be searched for in project.conf')
def _run(self, args: Namespace) -> None:
async def _run(self, args: Namespace) -> None:
import pathlib
proj_root = self.app.projs_root
log(DEBUG, "proj_root = " + proj_root)

View file

@ -14,5 +14,5 @@ class CmdOsCascade(Cmd): # export
super().add_arguments(parser)
def _run(self, args: Namespace) -> None:
async def _run(self, args: Namespace) -> None:
print(' '.join(self.app.os_cascade()))

View file

@ -15,7 +15,7 @@ class CmdPath(Cmd): # export
super().add_arguments(parser)
parser.add_argument('module', nargs='*', help='Modules')
def _run(self, args: Namespace) -> None:
async def _run(self, args: Namespace) -> None:
deps = self.app.get_modules_from_project_txt(args.module, ['pkg.requires.jw'], 'run',
scope = Scope.Subtree, add_self=True, names_only=True)
out = []

View file

@ -17,7 +17,7 @@ class CmdPrereq(Cmd): # export
parser.add_argument('flavour', help='Flavour')
parser.add_argument('module', nargs='*', help='Modules')
def _run(self, args: Namespace) -> None:
async def _run(self, args: Namespace) -> None:
deps = self.app.get_modules_from_project_txt(args.module, ['pkg.requires.jw'],
args.flavour, scope = Scope.Subtree, add_self=False, names_only=True)
print(' '.join(deps))

View file

@ -15,7 +15,7 @@ class CmdProjDir(Cmd): # export
super().add_arguments(parser)
parser.add_argument('module', nargs='*', help='Modules')
def _run(self, args: Namespace) -> None:
async def _run(self, args: Namespace) -> None:
out = []
for m in args.module:
path = self.app.find_dir(m)

View file

@ -15,7 +15,7 @@ class CmdPythonpath(Cmd): # export
super().add_arguments(p)
p.add_argument('module', help='Modules', nargs='*')
def _run(self, args: Namespace) -> None:
async def _run(self, args: Namespace) -> None:
deps = self.app.get_modules_from_project_txt(args.module, ['pkg.requires.jw'], [ 'run', 'build' ],
scope = Scope.Subtree, add_self=True, names_only=True)
out = []

View file

@ -15,7 +15,7 @@ class CmdPythonpathOrig(Cmd): # export
super().add_arguments(parser)
parser.add_argument('module', nargs='*', help='Modules')
def _run(self, args: Namespace) -> None:
async def _run(self, args: Namespace) -> None:
deps = self.app.get_modules_from_project_txt(args.module, ['pkg.requires.jw'], [ 'run', 'build' ],
scope = Scope.Subtree, add_self=True, names_only=True)
r = ''

View file

@ -20,7 +20,7 @@ class CmdRequiredOsPkg(Cmd): # export
parser.add_argument('--skip-excluded', action='store_true', default=False,
help='Output empty prerequisite list if module is excluded')
def _run(self, args: Namespace) -> None:
async def _run(self, args: Namespace) -> None:
modules = args.module
flavours = args.flavours.split()
if 'build' in flavours and not 'run' in flavours:

View file

@ -14,7 +14,7 @@ class CmdSummary(Cmd): # export
super().add_arguments(parser)
parser.add_argument('module', nargs='*', help='Modules')
def _run(self, args: Namespace) -> None:
async def _run(self, args: Namespace) -> None:
r = []
for m in args.module:
summary = self.app.get_value(m, "summary", None)

View file

@ -14,5 +14,5 @@ class CmdTest(Cmd): # export
super().add_arguments(parser)
parser.add_argument('blah', default='', help='The blah argument')
def _run(self, args: Namespace) -> None:
async def _run(self, args: Namespace) -> None:
print("blah = " + args.blah)

View file

@ -14,7 +14,7 @@ class CmdTmplDir(Cmd): # export
super().add_arguments(parser)
parser.add_argument('module', nargs='*', help='Modules')
def _run(self, args: Namespace) -> None:
async def _run(self, args: Namespace) -> None:
r = []
for m in args.module:
r.append(self.app.tmpl_dir(m))