schmeckels/cli
Felix Breidenstein e49e8c51f5 WIP
2020-10-18 18:05:05 +02:00

48 lines
1.1 KiB
Python
Executable file

#! /usr/bin/env python3
import click
import os
import sys
import importer
# import serve
# import autosort
# import validate
# import info
# import report
from helper import build_database_filename, create_dirs
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base
import models
@click.group()
def cli():
pass
@cli.command(name="init")
@click.argument("profile_name", required=True)
def init(profile_name):
filename = build_database_filename(profile_name)
if os.path.exists(filename):
print(f"Profile '{profile_name}' already exists")
sys.exit(1)
else:
engine = create_engine(f"sqlite:///{filename}")
models.Base.metadata.create_all(engine)
print(f"Sucessfully create the profile '{profile_name}'")
if __name__ == '__main__':
create_dirs()
# cli.add_command(sort.command)
cli.add_command(importer.command)
# cli.add_command(serve.command)
# cli.add_command(autosort.command)
# cli.add_command(validate.command)
# cli.add_command(info.command)
# cli.add_command(report.command)
cli()