diff --git a/python/revng/pypeline/cli/pipeline/run_analysis.py b/python/revng/pypeline/cli/pipeline/run_analysis.py index 38ef04efe..c21b10592 100644 --- a/python/revng/pypeline/cli/pipeline/run_analysis.py +++ b/python/revng/pypeline/cli/pipeline/run_analysis.py @@ -7,7 +7,7 @@ import sys import click from revng.pypeline.analysis import Analysis -from revng.pypeline.cli.utils import PypeGroup, build_arg_objects, build_help_text +from revng.pypeline.cli.utils import PypeCommand, PypeGroup, build_arg_objects, build_help_text from revng.pypeline.cli.utils import compute_objects, list_objects_option, normalize_whitespace from revng.pypeline.container import ContainerDeclaration from revng.pypeline.model import Model, ReadOnlyModel @@ -102,7 +102,11 @@ def build_run_analysis_command( analysis_type: type[Analysis], model_type: type[Model], ): - @click.command(name=analysis_name, help=help_text) + @click.command( + cls=PypeCommand, + name=analysis_name, + help=help_text, + ) @click.argument( "model", type=click.Path(exists=True, dir_okay=False, readable=True), diff --git a/python/revng/pypeline/cli/pipeline/run_pipe.py b/python/revng/pypeline/cli/pipeline/run_pipe.py index c773ae029..f0b7ff6f6 100644 --- a/python/revng/pypeline/cli/pipeline/run_pipe.py +++ b/python/revng/pypeline/cli/pipeline/run_pipe.py @@ -6,7 +6,7 @@ from pathlib import Path import click -from revng.pypeline.cli.utils import PypeGroup, build_arg_objects, build_help_text +from revng.pypeline.cli.utils import PypeCommand, PypeGroup, build_arg_objects, build_help_text from revng.pypeline.cli.utils import compute_objects, container_format_options from revng.pypeline.cli.utils import list_objects_option, normalize_kwarg_name from revng.pypeline.cli.utils import normalize_whitespace @@ -132,7 +132,11 @@ def build_pipe_command( pipe_type: type[Pipe], model_type: type[Model], ): - @click.command(name=pipe_name, help=help_text) + @click.command( + cls=PypeCommand, + name=pipe_name, + help=help_text, + ) @click.argument( "model", type=click.Path(exists=True, dir_okay=False, readable=True), diff --git a/python/revng/pypeline/cli/project/analyze.py b/python/revng/pypeline/cli/project/analyze.py index 9121dd103..78982db50 100644 --- a/python/revng/pypeline/cli/project/analyze.py +++ b/python/revng/pypeline/cli/project/analyze.py @@ -8,7 +8,7 @@ from typing import AsyncContextManager import click -from revng.pypeline.cli.utils import PypeGroup, build_arg_objects, build_help_text +from revng.pypeline.cli.utils import PypeCommand, PypeGroup, build_arg_objects, build_help_text from revng.pypeline.cli.utils import compute_objects, list_objects_for_container from revng.pypeline.cli.utils import list_objects_option, normalize_flag, normalize_whitespace from revng.pypeline.cli.utils import project_id_option, token_option @@ -188,7 +188,11 @@ def build_analysis_list_command( f"Invalidated {container_location}: [{', '.join(serialized_ids)}]" ) - @click.command(name=analysis_name, help=help_text) + @click.command( + cls=PypeCommand, + name=analysis_name, + help=help_text, + ) @list_objects_option @project_id_option @token_option @@ -284,7 +288,11 @@ def build_analysis_command( f"Invalidated {container_location}: [{', '.join(serialized_ids)}]" ) - @click.command(name=analysis_name, help=help_text) + @click.command( + cls=PypeCommand, + name=analysis_name, + help=help_text, + ) @list_objects_option @project_id_option @token_option diff --git a/python/revng/pypeline/cli/project/artifact.py b/python/revng/pypeline/cli/project/artifact.py index 3bfab36dd..6dbb6afd6 100644 --- a/python/revng/pypeline/cli/project/artifact.py +++ b/python/revng/pypeline/cli/project/artifact.py @@ -8,9 +8,9 @@ from typing import AsyncContextManager import click -from revng.pypeline.cli.utils import PypeGroup, build_help_text, container_format_options -from revng.pypeline.cli.utils import list_objects_option, normalize_whitespace, project_id_option -from revng.pypeline.cli.utils import token_option +from revng.pypeline.cli.utils import PypeCommand, PypeGroup, build_help_text +from revng.pypeline.cli.utils import container_format_options, list_objects_option +from revng.pypeline.cli.utils import normalize_whitespace, project_id_option, token_option from revng.pypeline.container import ContainerFormat from revng.pypeline.model import Model, ReadOnlyModel from revng.pypeline.object import ObjectID, ObjectSet @@ -160,6 +160,7 @@ def build_artifact_command( sys.stdout.buffer.flush() @click.command( + cls=PypeCommand, name=artifact_name, help=help_text, context_settings={ diff --git a/python/revng/pypeline/cli/project/daemon.py b/python/revng/pypeline/cli/project/daemon.py index ac0624101..b827099f3 100644 --- a/python/revng/pypeline/cli/project/daemon.py +++ b/python/revng/pypeline/cli/project/daemon.py @@ -9,11 +9,12 @@ import uvicorn import yaml import revng +from revng.pypeline.cli.utils import PypeCommand from revng.pypeline.daemon.app import make_starlette from revng.pypeline.daemon.daemon import Daemon -@click.command() +@click.command(cls=PypeCommand) @click.option( "--production", is_flag=True, diff --git a/python/revng/pypeline/cli/utils.py b/python/revng/pypeline/cli/utils.py index c846dfb03..8c80c3266 100644 --- a/python/revng/pypeline/cli/utils.py +++ b/python/revng/pypeline/cli/utils.py @@ -35,7 +35,10 @@ class PypeCommand(click.Command): ) def collect_usage_pieces(self, ctx: click.Context) -> list[str]: - return super().collect_usage_pieces(ctx) + ["--", "[PIPEBOX ARGS...]"] + if not isinstance(self, PypeGroup): + return super().collect_usage_pieces(ctx) + ["--", "[PIPEBOX ARGS...]"] + else: + return super().collect_usage_pieces(ctx) class PypeGroup(click.Group, PypeCommand): @@ -49,6 +52,11 @@ class PypeGroup(click.Group, PypeCommand): raise ValueError(f"All sub-groups must be of type PypeGroup, {name}: {type(cmd)}") return super().add_command(cmd, name) + def collect_usage_pieces(self, ctx: click.Context) -> list[str]: + rv = super().collect_usage_pieces(ctx) + rv.extend(["--", "[PIPEBOX ARGS...]"]) + return rv + class RegistryChoice(click.Choice): """A click.Choice that uses the registry of a given type, and