refactor: add paths, services ctx, and extract models to own files
This commit is contained in:
+9
-32
@@ -1,8 +1,10 @@
|
||||
import typer
|
||||
|
||||
from core.models import ServiceRegistry
|
||||
from config.paths import Paths
|
||||
from core.service_creator import ServiceCreator
|
||||
from core.utils import get_git_root, init_logging
|
||||
from models import ServiceRegistry
|
||||
from models.context import ServicesContext
|
||||
|
||||
service = typer.Typer(no_args_is_help=True)
|
||||
|
||||
@@ -40,46 +42,21 @@ def add(
|
||||
),
|
||||
):
|
||||
init_logging()
|
||||
service_creator = ServiceCreator(
|
||||
ctx = ServicesContext.load_from_disk(Paths())
|
||||
service_creator = ServiceCreator(ctx=ctx)
|
||||
service_creator.add_service(
|
||||
name=name,
|
||||
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/user/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()
|
||||
paths = Paths()
|
||||
registry = ServiceRegistry.read_from_file(paths.service_registry_file)
|
||||
services = registry.get_services()
|
||||
for service in services:
|
||||
print(service)
|
||||
|
||||
Reference in New Issue
Block a user