diff --git a/cli/Notes.md b/cli/Notes.md new file mode 100644 index 00000000..e3922121 --- /dev/null +++ b/cli/Notes.md @@ -0,0 +1,14 @@ +## CLI 开发备注 + +整个CLI采用MVC思想: + +* stackhub.py 代表视图层 V,用户体验层,专注体验编排,不进行条件编程 +* model.py 代表数据层 M。这是系统的最底层,都是与业务无关的系统级功能 +* controller.py 代表控制层 C。调用 M 层,针对业务编程 + +#### 用户如何获取项目清单? + +用户同步 stackhub 上已经存放的清单,而不是通过 API 获取。原因: + +1. 避免API使用需要授权或超时 +2. 避免未发布的应用被安装 \ No newline at end of file diff --git a/cli/__pycache__/controller.cpython-36.pyc b/cli/__pycache__/controller.cpython-36.pyc new file mode 100644 index 00000000..6277b815 Binary files /dev/null and b/cli/__pycache__/controller.cpython-36.pyc differ diff --git a/cli/__pycache__/core.cpython-36.pyc b/cli/__pycache__/core.cpython-36.pyc new file mode 100644 index 00000000..85be9f06 Binary files /dev/null and b/cli/__pycache__/core.cpython-36.pyc differ diff --git a/cli/__pycache__/model.cpython-36.pyc b/cli/__pycache__/model.cpython-36.pyc new file mode 100644 index 00000000..2cd27207 Binary files /dev/null and b/cli/__pycache__/model.cpython-36.pyc differ diff --git a/cli/controller.py b/cli/controller.py new file mode 100644 index 00000000..532fe10d --- /dev/null +++ b/cli/controller.py @@ -0,0 +1,12 @@ +import model + +path_repo = "./data/application.list" +path_project = "" + +class Print: + + def __init__(self): + pass + + def printRepo(): + model.FileOp.printJson(path_repo) \ No newline at end of file diff --git a/cli/install.sh b/cli/install.sh new file mode 100644 index 00000000..24dc8c31 --- /dev/null +++ b/cli/install.sh @@ -0,0 +1 @@ +yum install git pwgen jq wget curl figlet boxes -y \ No newline at end of file diff --git a/cli/core.py b/cli/model.py similarity index 78% rename from cli/core.py rename to cli/model.py index 0e31afe0..46881b6b 100644 --- a/cli/core.py +++ b/cli/model.py @@ -34,5 +34,18 @@ class Github: def __init__(self): pass - def -print(SmoothUrl.res(github_url)) \ No newline at end of file + def gitClone(): + pass + + + + +class FileOp: + '''File operation''' + + def __init__(self): + pass + + def printJson(path: str): + with open(path,newline='') as file: + print(file.read()) \ No newline at end of file diff --git a/cli/stackhub b/cli/stackhub deleted file mode 100644 index 424f1f9f..00000000 --- a/cli/stackhub +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -python3 stackhub.py \ No newline at end of file diff --git a/cli/stackhub.py b/cli/stackhub.py index f25e4c60..a07d1a3e 100644 --- a/cli/stackhub.py +++ b/cli/stackhub.py @@ -1,38 +1,48 @@ #!/usr/bin/env python3 import os, io, sys, platform, shutil, urllib3, json, time, subprocess +import model, controller import typer app = typer.Typer() - @app.command() -def list(name: str): +def list(): '''print the lists file''' - typer.echo(f"Hello {name}") + controller.Print.printRepo() @app.command() def update(name: str): '''update the local lists cache''' typer.echo(f"Hello {name}") -data + + @app.command() def upgrade(name: str): '''upgrade one application''' typer.echo(f"Hello {name}") + @app.command() def search(name: str): '''Search application you want to install''' typer.echo(f"Hello {name}") + @app.command() def show(name: str): '''show the detail of application''' typer.echo(f"Hello {name}") + + +@app.command() +def package(name: str): + '''package one application for no network environment''' + typer.echo(f"Hello {name}") + @app.command() def install(name: str, formal: bool = False, type: str = None):