Files
Javelina/cli.py
profitroll 1153a9441f
All checks were successful
Test / build (push) Successful in 26s
Fixed formatting with isort and black
2025-08-03 01:51:22 +02:00

42 lines
894 B
Python

from pathlib import Path
from shutil import copyfile
from typer import Option, Typer, echo
from javelina.modules.migrator import migrate_database
cli: Typer = Typer()
@cli.command()
def init(
destination: Path = Option(
"config.json", help="File to write the default configuration to"
),
overwrite: bool = Option(False, help="Overwrite config if already exists"),
) -> None:
example_path: Path = Path("config_example.json")
if destination.exists() and not overwrite:
raise FileExistsError(
f"File at {destination} already exists. Pass --overwrite to overwrite it"
)
copyfile(example_path, destination)
echo(f"Copied default config to {destination}")
@cli.command()
def migrate() -> None:
echo("Performing migrations...")
migrate_database()
def main() -> None:
cli()
if __name__ == "__main__":
main()