Skip to content

Commit 9a588df

Browse files
arimu1claude
andcommitted
Report program name as cwltool when invoked as cwl-runner (#1535)
argparse defaults prog to os.path.basename(sys.argv[0]), so running cwltool through its cwl-runner entry point made --help and error messages say "usage: cwl-runner ...". Set prog="cwltool" explicitly so the reference implementation is always identified consistently, regardless of which entry point was used. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 5634342 commit 9a588df

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

cwltool/argparser.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ def arg_parser() -> argparse.ArgumentParser:
8989
)
9090

9191
parser = argparse.ArgumentParser(
92+
prog="cwltool",
9293
formatter_class=RichHelpFormatter,
9394
description="Reference executor for Common Workflow Language standards. "
9495
"Not for production use.",

tests/test_toolargparse.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import argparse
2+
import sys
23
from collections.abc import Callable
34
from io import StringIO
45
from pathlib import Path
56

67
import pytest
78

89
import cwltool.executors
9-
from cwltool.argparser import generate_parser
10+
from cwltool.argparser import arg_parser, generate_parser
1011
from cwltool.context import LoadingContext
1112
from cwltool.load_tool import load_tool
1213
from cwltool.main import main
@@ -278,6 +279,15 @@ def test_argparser_without_doc() -> None:
278279
assert parser.description is None
279280

280281

282+
def test_argparser_prog_is_cwltool(monkeypatch: pytest.MonkeyPatch) -> None:
283+
"""The program name is reported as ``cwltool`` even when invoked as ``cwl-runner``.
284+
285+
Regression test for https://github.com/common-workflow-language/cwltool/issues/1535
286+
"""
287+
monkeypatch.setattr(sys, "argv", ["cwl-runner", "--help"])
288+
assert arg_parser().prog == "cwltool"
289+
290+
281291
@pytest.mark.parametrize(
282292
"job_order,expected_values",
283293
[

0 commit comments

Comments
 (0)