Commit 7fd0863c authored by Mickaël Desfrênes's avatar Mickaël Desfrênes
Browse files

most commands now accept --directory option pointing to the max project dir

parent ba3fb67b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
[project]
name = "climax-CERTIC"
version = "0.1.16"
version = "0.2.0"
description = "CLI tool for MaX, Le Moteur d'Affichage XML."
readme = "README.md"
license = {text = "CECILL-C"}
+22 −6
Original line number Diff line number Diff line
@@ -427,6 +427,7 @@ def demo(
    ] = os.getcwd(),
):
    check_dir_is_max(directory)
    os.chdir(directory)
    if typer.confirm(
        _("Voulez-vous installer une édition de démonstration ?"), default=False
    ):
@@ -486,6 +487,7 @@ def start(
        http_stop_port = http_port + 1
    http_stop_port = _closer_free_port_to(http_stop_port)
    check_dir_is_max(directory)
    os.chdir(directory)
    java_bin_path = ensure_java()
    process_args = [
        str(java_bin_path),
@@ -530,6 +532,7 @@ def stop(
    ] = os.getcwd(),
):
    check_dir_is_max(directory)
    os.chdir(directory)
    java_bin_path = ensure_java()
    process_args = [
        str(java_bin_path),
@@ -550,6 +553,7 @@ def info(
    ] = os.getcwd(),
):
    check_dir_is_max(directory)
    os.chdir(directory)
    config = max_config(directory)
    console = Console()
    table = Table(_("Nom"), _("Valeur"), show_lines=True)
@@ -564,11 +568,16 @@ def info(

@app.command(help=_("Fait une copie HTML statique"))
def freeze(
    directory: Annotated[
        Optional[Path], typer.Argument(help=_("chemin vers un dossier"))
    ] = Path(os.getcwd(), "output"),
    output: Annotated[
        str, typer.Option(help=_("Dossier de sortie des fichiers HTML"))
    ] = None,
    directory: Annotated[str, typer.Option(help=_("Dossier du projet MaX"))] = Path(
        os.getcwd()
    ),
    debug: bool = False,
):
    if output is None:
        output = Path(directory, "html_output")
    max_config(directory)
    # start server on specific port
    port_number = _free_port()
@@ -584,13 +593,13 @@ def freeze(
    # copy website
    try:
        start_url = f"http://localhost:{port_number}/"
        geler.freeze(start_url, directory)
        geler.freeze(start_url, output)
    except Exception as e:
        stop(stop_port)
        raise e
    # stop server
    stop(stop_port, directory)
    print("[green]" + _("Site copié dans {}").format(str(directory)) + "[/green]")
    print("[green]" + _("Site copié dans {}").format(str(output)) + "[/green]")


@app.command(help=_("Liste les bundles disponibles"))
@@ -600,6 +609,7 @@ def bundles_list(
    ] = os.getcwd(),
):
    check_dir_is_max(directory)
    os.chdir(directory)
    config = max_config(directory)
    console = Console()
    table = Table(_("Nom"), _("Installé"), _("Description"), show_lines=True)
@@ -635,6 +645,7 @@ def bundles_add(
):
    from_archive = None
    check_dir_is_max(directory)
    os.chdir(directory)
    config = max_config(directory)
    current_bundles_config = config.bundles
    # bundle_name is a local archive
@@ -702,6 +713,7 @@ def bundles_remove(
    ] = os.getcwd(),
):
    check_dir_is_max(directory)
    os.chdir(directory)
    config = max_config(directory)
    keep_bundles = {}
    bundle_name = bundle_name.lower().strip()
@@ -724,6 +736,7 @@ def feed(
    ] = os.getcwd(),
):
    check_dir_is_max(directory)
    os.chdir(directory)
    java_bin_path = ensure_java()
    feed_path = Path(feed_path).resolve()
    if not feed_path.is_file() and not feed_path.is_dir():
@@ -772,7 +785,7 @@ def feed(
)
def sync(
    directory: Annotated[
        Optional[Path], typer.Argument(help=_("chemin vers un dossier"))
        Optional[Path], typer.Argument(help=_("Dossier du projet MaX"))
    ] = os.getcwd(),
):
    ensure_java()
@@ -798,6 +811,7 @@ def basex(
    ] = os.getcwd(),
):
    check_dir_is_max(directory)
    os.chdir(directory)
    java_bin_path = ensure_java()
    process_args = [
        str(java_bin_path),
@@ -816,6 +830,7 @@ def templates_list(
    ] = os.getcwd(),
):
    check_dir_is_max(directory)
    os.chdir(directory)
    config = max_config(directory)
    vocab_bundle = config.vocabulary_bundle
    tpl_dir = Path(
@@ -846,6 +861,7 @@ def static_list(
    ] = os.getcwd(),
):
    check_dir_is_max(directory)
    os.chdir(directory)
    config = max_config(directory)
    vocab_bundle = config.vocabulary_bundle
    tpl_dir = Path(