82 lines
2.1 KiB
Python
82 lines
2.1 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
# IMPORTS
|
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
import os;
|
|
import sys;
|
|
|
|
_path_to_python_project = os.path.abspath(os.path.join(os.path.abspath(__file__), '..', '..'));
|
|
sys.path.insert(0, _path_to_python_project);
|
|
os.chdir(_path_to_python_project);
|
|
|
|
from src.core.log import *;
|
|
from src.core.utils import IsTrue;
|
|
from src.core.utils import IsFalse;
|
|
from src.setup.cli import *;
|
|
from src.setup import appconfig;
|
|
from src.endpoints.exports import *;
|
|
|
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
# GLOBAL VARIABLES/CONSTANTS
|
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
PATH_TO_CONFIG: str = '../config.yml';
|
|
|
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
# MAIN PROCESS
|
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
def enter(
|
|
mode: str,
|
|
it: bool,
|
|
quiet: bool,
|
|
debug: bool,
|
|
checks: bool,
|
|
colour: bool,
|
|
config: Any, **_
|
|
):
|
|
if not (mode == 'run' and it):
|
|
SetQuietMode(quiet);
|
|
SetDebugMode(debug);
|
|
SetAnsiMode(colour);
|
|
appconfig.SetAppConfigPerformChecks(checks);
|
|
|
|
config = config if isinstance(config, str) else PATH_TO_CONFIG;
|
|
|
|
if mode == 'version':
|
|
endpoint_version();
|
|
return;
|
|
elif mode == 'run':
|
|
if it:
|
|
endpoint_runInteractive();
|
|
else:
|
|
endpoint_runNonInteractive(path=config);
|
|
else: # elif mode
|
|
endpoint_help();
|
|
return;
|
|
return;
|
|
|
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
# EXECUTE CODE
|
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
if __name__ == '__main__':
|
|
sys.tracebacklimit = 0;
|
|
try:
|
|
args = GetArgumentsFromCli(*sys.argv[1:]);
|
|
except Exception as e:
|
|
endpoint_help();
|
|
exit(1);
|
|
enter(
|
|
mode=args.mode[0],
|
|
it=args.it,
|
|
quiet=args.quiet,
|
|
debug=args.debug,
|
|
checks=IsTrue(args.checks[0]),
|
|
colour=IsTrue(args.colour[0]),
|
|
config=args.config,
|
|
);
|