outsource setting of flags into own function
This commit is contained in:
parent
0295bcee2e
commit
a30d7ef0de
|
|
@ -15,11 +15,8 @@ from models import Log
|
||||||
def backup():
|
def backup():
|
||||||
backup_status = True
|
backup_status = True
|
||||||
|
|
||||||
# Fetch arguments
|
# Set flags
|
||||||
utils.all_containers = "--all" in sys.argv
|
utils.set_flags(sys.argv)
|
||||||
utils.quiet_mode = "--quiet" in sys.argv
|
|
||||||
utils.no_log = "--nolog" in sys.argv
|
|
||||||
utils.no_cleanup = "--nocleanup" in sys.argv
|
|
||||||
|
|
||||||
# Load settings
|
# Load settings
|
||||||
settings = Path(__file__).parent / "settings.yaml"
|
settings = Path(__file__).parent / "settings.yaml"
|
||||||
|
|
|
||||||
|
|
@ -20,11 +20,8 @@ from simple_term_menu import TerminalMenu
|
||||||
def restore():
|
def restore():
|
||||||
restore_status = True
|
restore_status = True
|
||||||
|
|
||||||
# Fetch arguments
|
# Set flags
|
||||||
utils.all_containers = "--all" in sys.argv
|
utils.set_flags(sys.argv)
|
||||||
utils.quiet_mode = "--quiet" in sys.argv
|
|
||||||
utils.no_log = "--nolog" in sys.argv
|
|
||||||
utils.no_confirm = "--yes" in sys.argv
|
|
||||||
|
|
||||||
# Load settings
|
# Load settings
|
||||||
settings = Path(__file__).parent / "settings.yaml"
|
settings = Path(__file__).parent / "settings.yaml"
|
||||||
|
|
|
||||||
|
|
@ -15,11 +15,8 @@ from models import Log
|
||||||
def upgrade():
|
def upgrade():
|
||||||
upgrade_status = True
|
upgrade_status = True
|
||||||
|
|
||||||
# Fetch arguments
|
# Set flags
|
||||||
utils.all_containers = "--all" in sys.argv
|
utils.set_flags(sys.argv)
|
||||||
utils.quiet_mode = "--quiet" in sys.argv
|
|
||||||
utils.no_log = "--nolog" in sys.argv
|
|
||||||
utils.no_cleanup = "--nocleanup" in sys.argv
|
|
||||||
|
|
||||||
# Load settings
|
# Load settings
|
||||||
settings = Path(__file__).parent / "settings.yaml"
|
settings = Path(__file__).parent / "settings.yaml"
|
||||||
|
|
|
||||||
17
utils.py
17
utils.py
|
|
@ -6,7 +6,24 @@ all_containers = False
|
||||||
no_confirm = 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):
|
def _print(text=None):
|
||||||
|
global quiet_mode
|
||||||
if not quiet_mode:
|
if not quiet_mode:
|
||||||
if not text is None:
|
if not text is None:
|
||||||
print(text)
|
print(text)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue