80 lines
2.6 KiB
Python
80 lines
2.6 KiB
Python
import typer
|
|
|
|
from core.models import ServiceRegistry
|
|
from core.service_creator import ServiceCreator
|
|
from core.utils import get_git_root, init_logging
|
|
|
|
service = typer.Typer(no_args_is_help=True)
|
|
|
|
REPO_ROOT = get_git_root(__file__)
|
|
|
|
|
|
@service.command(
|
|
no_args_is_help=True,
|
|
help="Running this command will create a new branch 'feature/add-service-<name>', "
|
|
"add all the required files for a new service, and push. "
|
|
"See: https://gitea.psi.ch/sls/hla_framework_bd/branches",
|
|
)
|
|
def add(
|
|
name: str = typer.Option(
|
|
..., "--name", "-n", help="Must only contain lowercase characters and dashes"
|
|
),
|
|
user: str = typer.Option(..., "--user", "-u", help="PSI username of the owner of the service"),
|
|
ioc_description: str = typer.Option(
|
|
..., "--ioc-description", "-d", help="See <repo-root>/docs/ioc/ioc_overview.md for examples"
|
|
),
|
|
ui_name: str = typer.Option(
|
|
...,
|
|
"--ui-name",
|
|
help="This is the name that will be used for the service in the UI. "
|
|
"See <repo-root>/qt/A_BD_ServiceManager.ui for examples",
|
|
),
|
|
ui_filename: str = typer.Option(
|
|
...,
|
|
"--ui-filename",
|
|
"-f",
|
|
help="The <ui-filename> in 'A_BD_<ui-filename>.ui'; See <repo-root>/qt/A_BD_ServiceManager.ui for examples",
|
|
),
|
|
):
|
|
init_logging()
|
|
service_creator = ServiceCreator(
|
|
user=user, # TODO: read from 'whoami'?
|
|
ioc_description=ioc_description,
|
|
ui_name=ui_name, # TODO: make this standard?
|
|
ui_filename=ui_filename, # TODO: make this standard?
|
|
)
|
|
service_creator.add_service(name=name)
|
|
|
|
|
|
# TODO: remove
|
|
@service.command(no_args_is_help=True)
|
|
def migrate(
|
|
name: str = typer.Option(..., "--name", "-n"),
|
|
user: str = typer.Option(..., "--user", "-u"),
|
|
ioc_description: str = typer.Option(
|
|
..., "--ioc-description", "-d", help="See <repo-root>/docs/ioc/ioc_overview.md for examples"
|
|
),
|
|
ui_filename: str = typer.Option(
|
|
...,
|
|
"--ui-filename",
|
|
"-f",
|
|
help="The <ui-filename> in 'A_BD_<ui-filename>.ui'; See <repo-root>/qt/A_BD_ServiceManager.ui for examples",
|
|
),
|
|
):
|
|
init_logging()
|
|
service_creator = ServiceCreator(
|
|
user=user, # TODO: read from 'whoami'?
|
|
ioc_description=ioc_description,
|
|
ui_name="",
|
|
ui_filename=ui_filename, # TODO: make this standard?
|
|
)
|
|
service_creator.migrate_service(name=name)
|
|
|
|
|
|
@service.command()
|
|
def list():
|
|
registry = ServiceRegistry.read_from_config()
|
|
services = registry.get_services()
|
|
for service in services:
|
|
print(service)
|