diff --git a/cli/controller.py b/cli/controller.py index 27714600..a58170e3 100644 --- a/cli/controller.py +++ b/cli/controller.py @@ -9,11 +9,17 @@ github_url = ("https://github.com", "https://hub.fastgit.org", "https://github.c class Print: - def __init__(self): - pass + '''display all any information you want''' + + def __init__(self, status: Optional[str] = 'all'): + self.status = status def printRepo(): model.FileOp.printJson(path_repo) + + def lsProject(self): + ls = model.DockerOp(self.status) + ls.lsProject() class Create: diff --git a/cli/model.py b/cli/model.py index 53cdb4e1..0f0d3567 100644 --- a/cli/model.py +++ b/cli/model.py @@ -156,18 +156,26 @@ class DockerComposeOp: class DockerOp: ''' Docker operation ''' - def __init__(self): + def __init__(self, status: Optional[str] = 'all'): self.client = docker.from_env() + self.status = status def lsContainer(self): container_list = [] - for container in self.client.containers.list(all): + for container in self.client.containers.list(self.status): container_list.append(container.name) return container_list - def lsProject(self): + def getProject(self): project_dict = {} for name in self.lsContainer(): - print(self.client.containers.get(name).labels) \ No newline at end of file + project_dict[self.client.containers.get(name).labels['com.docker.compose.project']] = self.client.containers.get(name).labels['com.docker.compose.project.working_dir'] + + return project_dict + + def lsProject(self): + '''list all project and path''' + for key, value in self.getProject().items(): + print(key,value) \ No newline at end of file diff --git a/cli/stackhub.py b/cli/stackhub.py index 9cd10a1a..e7039857 100644 --- a/cli/stackhub.py +++ b/cli/stackhub.py @@ -9,9 +9,10 @@ import typer app = typer.Typer() @app.command() -def list(): - '''print the lists file''' - controller.Print.printRepo() +def ls(status: Optional[str] = 'all'): + '''list all the project have installed''' + print = controller.Print(status) + print.lsProject() @app.command() def create(app_name: str, project_name: Optional[str] = None):