76 lines
1.4 KiB
Python
Executable File
76 lines
1.4 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import argparse
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parent.parent
|
|
|
|
sys.path.insert(0, str(ROOT))
|
|
|
|
from core.configuration import (
|
|
ConfigurationError,
|
|
load_config,
|
|
)
|
|
|
|
|
|
def main():
|
|
|
|
parser = argparse.ArgumentParser(
|
|
description="ABSDEV Deployment Framework"
|
|
)
|
|
|
|
parser.add_argument(
|
|
"--version",
|
|
action="version",
|
|
version=(ROOT / "VERSION").read_text().strip(),
|
|
)
|
|
|
|
commands = parser.add_subparsers(
|
|
dest="command",
|
|
required=True,
|
|
)
|
|
|
|
validate = commands.add_parser(
|
|
"validate",
|
|
help="Validate site configuration without deployment",
|
|
)
|
|
|
|
validate.add_argument(
|
|
"--config",
|
|
required=True,
|
|
type=Path,
|
|
)
|
|
|
|
args = parser.parse_args()
|
|
|
|
try:
|
|
|
|
if args.command == "validate":
|
|
|
|
config = load_config(args.config)
|
|
|
|
print("PASS: Configuration valid")
|
|
print("Site:", config["site"]["identifier"])
|
|
print("Domain:", config["site"]["domain"])
|
|
print("Database:", config["database"]["driver"])
|
|
print("Schema:", config["schema_version"])
|
|
print("No deployment performed")
|
|
|
|
return 0
|
|
|
|
except ConfigurationError as error:
|
|
|
|
print(
|
|
f"ERROR: {error}",
|
|
file=sys.stderr,
|
|
)
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|