Pypeline: fix pipebox args usage string on cli

The usage strings didn't always show '-- [PYPEBOX ARGS...]' or didn't
show it at the end of the usage string. This commit fixes it.
This commit is contained in:
Tommaso Fontana
2025-11-20 14:54:21 +01:00
committed by Giacomo Vercesi
parent 91299b0c18
commit 4e73bc05f3
6 changed files with 38 additions and 12 deletions
@@ -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),
@@ -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),
+11 -3
View File
@@ -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
@@ -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={
+2 -1
View File
@@ -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,
+9 -1
View File
@@ -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