feat: add manager, entry and command
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
from ..command import Command
|
||||
|
||||
__all__ = ("PoetryCommand",)
|
||||
|
||||
|
||||
class PoetryCommand(Command):
|
||||
EXECUTOR: str = "poetry"
|
||||
|
||||
def __init__(self, *args: str) -> None:
|
||||
super().__init__(self.EXECUTOR, *args)
|
||||
|
||||
@classmethod
|
||||
def env_use(cls, python_version: str) -> "PoetryCommand":
|
||||
return cls("env", "use", python_version)
|
||||
|
||||
@classmethod
|
||||
def install(cls) -> "PoetryCommand":
|
||||
return cls("install")
|
||||
@@ -0,0 +1,22 @@
|
||||
from pathlib import Path
|
||||
from typing import Optional
|
||||
|
||||
from ..entry import Entry
|
||||
from .command import PoetryCommand
|
||||
|
||||
|
||||
class PythonEntry(Entry):
|
||||
TYPE: str = "python"
|
||||
|
||||
def __init__(self, basepath: Path):
|
||||
super().__init__(self.TYPE, basepath)
|
||||
|
||||
def setup(self):
|
||||
self._logger.info(f"setup:{self}")
|
||||
PoetryCommand.env_use("3.8").run(self._basepath)
|
||||
PoetryCommand.install().run(self._basepath)
|
||||
|
||||
@classmethod
|
||||
def detect(cls, basepath: Path) -> Optional["PythonEntry"]:
|
||||
if (basepath / "pyproject.toml").exists():
|
||||
return cls(basepath)
|
||||
Reference in New Issue
Block a user