Commit 64b86e97 authored by Mickaël Desfrênes's avatar Mickaël Desfrênes
Browse files

add basic feed command

parent 97ca2477
Loading
Loading
Loading
Loading
+44
Changes for src/climax/__main__.py: 44 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -840,6 +840,50 @@ def bundles_add(bundle_name: str):
                    bundles_list()


@app.command(help=_("Ajoute un fichier XML à l'instance de Max en cours"))
def feed(xml_file: Path):
    xml_file = Path(xml_file)
    if not xml_file.is_file():
        print(_("[red]{} n'est pas un fichier XML[/red]").format(xml_file))
        raise typer.Exit(code=1)
    check_cwd_is_max()
    java_bin_path = ensure_java()
    # "if(not(db:exists('max'))) then db:create('max') else ()"
    process_args = [
        str(java_bin_path),
        "-cp",
        cp_paths(),
        "-Xmx2g",
        "org.basex.BaseX",
        "if(not(db:exists('max'))) then db:create('max') else ()",
    ]
    subprocess.run(process_args)
    process_args = [
        str(java_bin_path),
        "-cp",
        cp_paths(),
        "-Xmx2g",
        "org.basex.BaseX",
        f"-cOPEN max; ADD {xml_file.resolve()}",
    ]
    subprocess.run(process_args)


@app.command(help=_("Lance le client de BaseX"))
def basex():
    check_cwd_is_max()
    java_bin_path = ensure_java()
    # "if(not(db:exists('max'))) then db:create('max') else ()"
    process_args = [
        str(java_bin_path),
        "-cp",
        cp_paths(),
        "-Xmx2g",
        "org.basex.BaseX",
    ]
    subprocess.run(process_args)


get_yolk()

if __name__ == "__main__":