This commit is contained in:
ahmadbilalkhalid 2019-09-14 12:15:33 +05:00
parent 0b269ef2ff
commit b75cfcf801
1 changed files with 47 additions and 0 deletions

47
app/cli.py Normal file
View File

@ -0,0 +1,47 @@
import click
import subprocess as sp
import os
from app.helper import install_available
@click.group()
def cli():
pass
@cli.command("setup")
@click.option("--path", required=True)
@click.option("--api_server", required=True)
def setup(path, api_server):
os.chdir(path)
repo_name = "ucloud-cli"
# Clone main repo
sp.check_output(['git', 'clone', '--single-branch', '--branch', 'wip',
f'https://code.ungleich.ch/ucloud/{repo_name}.git'])
# Create .env file
with open(os.path.join(repo_name, ".env"), "w") as f:
content = (
f"API_SERVER={api_server}\n"
)
f.writelines(content)
# Clone Common and Etcd Wrapper
# clone_common(path=repo_name)
# clone_etcd_wrapper(path=repo_name)
# Copy Etcd Wrapper inside ucloud_common as ucloud_common
# also needs etcd wrapper
# shutil.copytree(
# src=os.path.join(repo_name, "etcd3_wrapper"),
# dst=os.path.join(repo_name, "ucloud_common", "etcd3_wrapper"),
# )
install_available(repo_name)
# Create virtualenv with site-packages enabled and install all dependencies
# sp.check_output(['pipenv','--site-packages', '--three'], cwd=repo_name)
sp.check_output(['pipenv', 'install'], cwd=repo_name)