cmds.distro.CmdInfo: Rename to cmds.platform.CmdInfo

Rename command "distro" to "pkg" together with "info", its last
remaining subcommand. "distro" is often used in the sense of "Linux
distribution", which would be too narrow for the targets jw-pkg could
theoretically support.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-04-24 12:16:20 +02:00
commit 514d66dac1
Signed by: Jan Lindemann
GPG key ID: 3750640C9E25DD61
5 changed files with 20 additions and 20 deletions

View file

@ -0,0 +1,15 @@
# -*- coding: utf-8 -*-
from argparse import ArgumentParser
from ..App import App
from .Cmd import Cmd as CmdBase
class CmdPlatform(CmdBase): # export
def __init__(self, parent: App) -> None:
super().__init__(parent, 'platform', help="Miscellaneous platform-related comamnds")
self._add_subcommands()
def add_arguments(self, p: ArgumentParser) -> None:
super().add_arguments(p)

View file

@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
from __future__ import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from ...lib.Distro import Distro
from ..CmdPlatform import CmdPlatform
from ..Cmd import Cmd as Base
class Cmd(Base): # export
def __init__(self, parent: CmdPlatform, name: str, help: str) -> None:
super().__init__(parent, name, help)

View file

@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
from argparse import Namespace, ArgumentParser
from ...lib.log import *
from ...lib.Distro import Distro
from ..Cmd import Cmd
from ..CmdPlatform import CmdPlatform
class CmdInfo(Cmd): # export
def __init__(self, parent: CmdPlatform) -> None:
super().__init__(parent, 'info', help='Retrieve information about target platform')
def add_arguments(self, parser: ArgumentParser) -> None:
super().add_arguments(parser)
parser.add_argument('--format', default='%{cascade}',
help=f'Format string, expanding macros {", ".join(Distro.macros())}')
async def _run(self, args: Namespace) -> None:
print(self.app.distro.expand_macros(args.format))

View file

@ -0,0 +1,5 @@
TOPDIR = ../../../../../..
PY_UPDATE_INIT_PY = false
include $(TOPDIR)/make/proj.mk
include $(JWBDIR)/make/py-mod.mk

View file

@ -0,0 +1,11 @@
import importlib, pkgutil
__all__ = []
for finder, module_name, ispkg in pkgutil.iter_modules(__path__):
if not module_name.startswith("Cmd"):
continue
module = importlib.import_module(f".{module_name}", __name__)
cls = getattr(module, module_name)
globals()[module_name] = cls
__all__.append(module_name)