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():
|
||||
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"
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
17
utils.py
17
utils.py
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue