Skip to content

fix: wire --regex-pattern through the CLI (#175)#180

Open
patchwright wants to merge 1 commit into
un33k:masterfrom
patchwright:fix/cli-regex-pattern
Open

fix: wire --regex-pattern through the CLI (#175)#180
patchwright wants to merge 1 commit into
un33k:masterfrom
patchwright:fix/cli-regex-pattern

Conversation

@patchwright

Copy link
Copy Markdown

Fixes #175.

Problem

The CLI defines --regex-pattern in parse_args, but slugify_params() never passes regex_pattern to slugify() — every other argument is wired except that one. So the flag is silently dropped:

$ slugify --regex-pattern "[^-a-z0-9_]+" "___This is a test___"
this-is-a-test          # expected: ___this-is-a-test___

(@peter-bloomfield reported it; @jdevera confirmed the missing wiring.)

Fix

Add regex_pattern=args.regex_pattern to the slugify_params() dict. argparse already defaults it to None when the flag is absent, which matches slugify()'s own default, so existing behavior is unchanged.

Tests

  • Added regex_pattern to TestCommandParams.DEFAULTS so test_defaults now covers it.
  • test_regex_pattern: the flag flows through to params.
  • test_regex_pattern_end_to_end: reproduces the exact example from --regex-pattern option ignored by CLI #175 and asserts ___this-is-a-test___.

Both new tests fail on the current main (KeyError / wrong output) and pass with the fix. Full suite: 84 passed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--regex-pattern option ignored by CLI

1 participant