#! /usr/bin/env python3 import click import os import sys from pathlib import Path import importer # import serve import autosort import validate # import info # import report from helper import build_database_filename, create_dirs, build_rules_filename 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): db_path = build_database_filename(profile_name) rule_path = build_rules_filename(profile_name) if os.path.exists(db_path) and os.path.exists(rule_path): print(f"Profile '{profile_name}' already exists") sys.exit(1) else: # database engine = create_engine(f"sqlite:///{db_path}") models.Base.metadata.create_all(engine) # rules Path(rule_path).touch() 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()