outsource setting of flags into own function

This commit is contained in:
Marc Koch 2020-12-16 23:01:41 +01:00
parent 0295bcee2e
commit a30d7ef0de
Signed by: marc
GPG Key ID: AC2D4E00990A6767
4 changed files with 23 additions and 15 deletions

View File

@ -15,11 +15,8 @@ from models import Log
def backup():
backup_status = True
# Fetch arguments
utils.all_containers = "--all" in sys.argv
utils.quiet_mode = "--quiet" in sys.argv
utils.no_log = "--nolog" in sys.argv
utils.no_cleanup = "--nocleanup" in sys.argv
# Set flags
utils.set_flags(sys.argv)
# Load settings
settings = Path(__file__).parent / "settings.yaml"

View File

@ -20,11 +20,8 @@ from simple_term_menu import TerminalMenu
def restore():
restore_status = True
# Fetch arguments
utils.all_containers = "--all" in sys.argv
utils.quiet_mode = "--quiet" in sys.argv
utils.no_log = "--nolog" in sys.argv
utils.no_confirm = "--yes" in sys.argv
# Set flags
utils.set_flags(sys.argv)
# Load settings
settings = Path(__file__).parent / "settings.yaml"

View File

@ -15,11 +15,8 @@ from models import Log
def upgrade():
upgrade_status = True
# Fetch arguments
utils.all_containers = "--all" in sys.argv
utils.quiet_mode = "--quiet" in sys.argv
utils.no_log = "--nolog" in sys.argv
utils.no_cleanup = "--nocleanup" in sys.argv
# Set flags
utils.set_flags(sys.argv)
# Load settings
settings = Path(__file__).parent / "settings.yaml"

View File

@ -6,7 +6,24 @@ all_containers = False
no_confirm = False
def set_flags(flags=list):
global quiet_mode
global no_log
global no_cleanup
global all_containers
global no_confirm
global no_backup
quiet_mode = "--quiet" in flags
no_log = "--nolog" in flags
all_containers = "--all" in flags
no_cleanup = "--nocleanup" in flags
no_confirm = "--yes" in flags
def _print(text=None):
global quiet_mode
if not quiet_mode:
if not text is None:
print(text)