[manage.py] Add command arguments for action & target projects
This commit is contained in:
parent
252c827d92
commit
5993328cdb
1 changed files with 20 additions and 11 deletions
31
manage.py
31
manage.py
|
@ -300,28 +300,37 @@ def main():
|
|||
|
||||
print("\nUsing socket " + env['socket'] + ".")
|
||||
|
||||
print("\nChoose action:")
|
||||
print("[1/S] Setup project")
|
||||
print("[2/U] Update project")
|
||||
print("[3/B] Backup project")
|
||||
|
||||
action = ''
|
||||
if len(sys.argv) > 1:
|
||||
action = sys.argv[1]
|
||||
else:
|
||||
print("\nChoose action:")
|
||||
print("[1/S] Setup project")
|
||||
print("[2/U] Update project")
|
||||
print("[3/B] Backup project")
|
||||
|
||||
while action == '':
|
||||
action = input("Action: ")
|
||||
|
||||
|
||||
projects = os.listdir("projects")
|
||||
print(f"\nProjects list: {projects}")
|
||||
|
||||
target_projects = input("Target compose project(s), space separated, leave empty to target all: ")
|
||||
if len(sys.argv) > 2:
|
||||
target_projects = sys.argv[2]
|
||||
else:
|
||||
target_projects = input("Target compose project(s), space separated, leave empty to target all: ")
|
||||
|
||||
if target_projects == '':
|
||||
target_projects = projects
|
||||
else:
|
||||
target_projects = target_projects.split(' ')
|
||||
target_projects = re.split(' ?, ?| ', target_projects.strip())
|
||||
|
||||
print(f"Target projects: {target_projects}")
|
||||
|
||||
match action:
|
||||
case '1' | 'S':
|
||||
|
||||
match action.casefold():
|
||||
case '1' | 's' | 'setup':
|
||||
setNftables()
|
||||
|
||||
for project in target_projects:
|
||||
|
@ -332,7 +341,7 @@ def main():
|
|||
print(e, file=sys.stderr)
|
||||
print(f"Failed to setup project {project}.", file=sys.stderr)
|
||||
|
||||
case '2' | 'U':
|
||||
case '2' | 'u' | 'update':
|
||||
for project in target_projects:
|
||||
try:
|
||||
print()
|
||||
|
@ -341,7 +350,7 @@ def main():
|
|||
print(e, file=sys.stderr)
|
||||
print(f"Failed to update project {project}.", file=sys.stderr)
|
||||
|
||||
case '3' | 'B':
|
||||
case '3' | 'b' | 'backup':
|
||||
print()
|
||||
if not os.path.exists(env['borg_repo']):
|
||||
print(f"Creating borg repository {env['borg_repo']}.")
|
||||
|
|
Loading…
Reference in a new issue