From 6de74c3ee3d3d69a33bc889cef20752ce53beaea Mon Sep 17 00:00:00 2001 From: Julio Faerman <356476+faermanj@users.noreply.github.com> Date: Wed, 18 Oct 2023 22:48:26 +0200 Subject: [PATCH] wip --- up_cli/src/up_cli/__init__.py | 25 ++++++++++++++++--------- up_cli/src/up_cli/hookspec.py | 5 +---- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/up_cli/src/up_cli/__init__.py b/up_cli/src/up_cli/__init__.py index 8c58ed8..59c5e2d 100644 --- a/up_cli/src/up_cli/__init__.py +++ b/up_cli/src/up_cli/__init__.py @@ -1,25 +1,32 @@ import pluggy from dataclasses import dataclass -from typing import List +from typing import TypeAlias +from typing import Callable hookimpl = pluggy.HookimplMarker("up") pm = pluggy.PluginManager("up") -def match_prompt(prompt, head, image): - if not prompt: - return None - if prompt[0] == head: - return image - return None - # https://docker-py.readthedocs.io/en/stable/containers.html @dataclass class RunConfig: name: str image: str - command: List[str] + command: list[str] environment: dict[str, str] ports: dict[str, str] auto_remove: bool = True network_mode: str = "host" # volumes: dict[str, str] + +RunConfigs:TypeAlias = list[RunConfig] +Prompt:TypeAlias = list[str] + +def match_prompt(prompt: Prompt, + mk_run_config: Callable[[], RunConfig], + *args) -> list[RunConfig]: + if not prompt: + return None + #TODO: implement matching + return None + + diff --git a/up_cli/src/up_cli/hookspec.py b/up_cli/src/up_cli/hookspec.py index f631c4d..053cb6f 100644 --- a/up_cli/src/up_cli/hookspec.py +++ b/up_cli/src/up_cli/hookspec.py @@ -1,11 +1,8 @@ import pluggy - +from up_cli import Prompt, RunConfigs hookspec = pluggy.HookspecMarker("up") -RunConfigs = List[float] -Prompt = list[str] - @hookspec(firstresult=True) def to_run_configs(prompt: Prompt) -> RunConfigs: """Present run configurations to execute for prompt"""