From 25c4057076f4406721ae5d44297bd6c997472bb6 Mon Sep 17 00:00:00 2001 From: python-slugify-1 Date: Wed, 14 Oct 2026 12:42:12 +0000 Subject: [PATCH] fix(cli): correct --max-length flag name in help text The --word-boundary and --save-order help strings referred to a --max_length (underscore) flag that argparse does not register; copying the name from the help yields "unrecognized arguments". Use the actual --max-length spelling and add a regression test that captures the parser help. Refs #1 --- slugify/__main__.py | 4 ++-- tests/test_cli_interrupt.py | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/slugify/__main__.py b/slugify/__main__.py index fde2a86..b740db1 100644 --- a/slugify/__main__.py +++ b/slugify/__main__.py @@ -25,9 +25,9 @@ def parse_args(argv: list[str]) -> argparse.Namespace: parser.add_argument("--max-length", type=int, default=0, help="Output string length, 0 for no limit") parser.add_argument("--word-boundary", action='store_true', default=False, - help="Truncate to complete word even if length ends up shorter than --max_length") + help="Truncate to complete word even if length ends up shorter than --max-length") parser.add_argument("--save-order", action='store_true', default=False, - help="When set and --max_length > 0 return whole words in the initial order") + help="When set and --max-length > 0 return whole words in the initial order") parser.add_argument("--separator", type=str, default=DEFAULT_SEPARATOR, help="Separator between words. By default " + DEFAULT_SEPARATOR) parser.add_argument("--stopwords", nargs='+', diff --git a/tests/test_cli_interrupt.py b/tests/test_cli_interrupt.py index eda9337..463cb0f 100644 --- a/tests/test_cli_interrupt.py +++ b/tests/test_cli_interrupt.py @@ -21,3 +21,11 @@ def test_keyboard_interrupt_exits_without_traceback(capsys): captured = capsys.readouterr() assert captured.out == '' assert captured.err == '' + + +def test_help_uses_hyphenated_max_length(capsys): + with pytest.raises(SystemExit): + cli.main(['slugify', '--help']) + out = capsys.readouterr().out + assert '--max_length' not in out + assert '--max-length' in out