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:
parent
5830984bfc
commit
514d66dac1
5 changed files with 20 additions and 20 deletions
15
src/python/jw/pkg/cmds/CmdPlatform.py
Normal file
15
src/python/jw/pkg/cmds/CmdPlatform.py
Normal 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)
|
||||
16
src/python/jw/pkg/cmds/platform/Cmd.py
Normal file
16
src/python/jw/pkg/cmds/platform/Cmd.py
Normal 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)
|
||||
21
src/python/jw/pkg/cmds/platform/CmdInfo.py
Normal file
21
src/python/jw/pkg/cmds/platform/CmdInfo.py
Normal 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))
|
||||
5
src/python/jw/pkg/cmds/platform/Makefile
Normal file
5
src/python/jw/pkg/cmds/platform/Makefile
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
TOPDIR = ../../../../../..
|
||||
PY_UPDATE_INIT_PY = false
|
||||
|
||||
include $(TOPDIR)/make/proj.mk
|
||||
include $(JWBDIR)/make/py-mod.mk
|
||||
11
src/python/jw/pkg/cmds/platform/__init__.py
Normal file
11
src/python/jw/pkg/cmds/platform/__init__.py
Normal 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)
|
||||
Loading…
Reference in a new issue