-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
56 lines (48 loc) · 1.76 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from settings import console, typer, app
from pathlib import PurePath, Path
from subprocess import check_output
import os
# - - - - - - - - - - - - - - - - - - - - - - - -
@app.command()
def new(
repo:str = typer.Option(Path.cwd().parts[-1], prompt="Repo name")
):
user = 'ab22375'
pwd = os.environ['ENV_GTH']
cmd_create_repo = f'curl -i -H "Authorization: token {pwd}"'
cmd_create_repo += " -d '{"
cmd_create_repo += f'"name": "{repo}",'
# cmd_create_repo += '"auto_init": true,'
cmd_create_repo += '"private": true'
cmd_create_repo += f"}}' https://api.github.com/user/repos"
if True:
cmds = []
cmds.append('git init')
cmds.append(cmd_create_repo)
# cmds.append('curl -u \'' + usr + '\' https://api.github.com/user/repos -d \'{"name" : "' + repo + '"}\'')
# cmds.append(f'git remote add origin git@github.com:ab22375/{repo}.git')
# cmds.append('git add .')
# cmds.append('git commit -m "first commit"')
# cmds.append('git push --set-upstream origin master')
for cmd in cmds:
console.print(cmd)
check_output(cmd, shell=True, cwd=Path.cwd())
# - - - - - - - - - - - - - - - - - - - - - - - -
@app.command()
def add(
comment: str = typer.Option('upd', prompt="Comment: ")
):
cmds = []
cmds.append("git add .")
cmds.append(f'git commit -m "{comment}" ')
cmds.append("git push")
for cmd in cmds:
typer.echo(cmd)
try:
check_output(cmd, shell=True, cwd="./") #, cwd=folder)
except:
console.print('-'*30, '\n\n ==>> Error\n\n','-'*30)
console.print('*** END ***')
# - - - - - - - - - - - - - - - - - - - - - - - - - - -
if __name__ == "__main__":
app()