Summary
The --preserve-case feature generates case variants for camelCase and underscore_separated names, but does not handle dash-separated (kebab-case) names like my-component or some-value.
Details
There is a TODO at line 688 of repren.py:
# TODO: Could handle dash-separated names as well.
The _split_name() function currently checks for underscores first, then falls back to camelCase splitting. Dash-separated names (common in CSS class names, HTML attributes, CLI flags, file names, and package names) are not recognized — the entire string is treated as one word.
Example
With --preserve-case --from my-component --to new-widget:
Current behavior: Only matches literal my-component → new-widget
Expected behavior: Should also generate:
my-component → new-widget (kebab-case)
my_component → new_widget (snake_case)
myComponent → newWidget (camelCase)
MyComponent → NewWidget (PascalCase)
MY_COMPONENT → NEW_WIDGET (SCREAMING_SNAKE)
Suggestion
Extend _split_name() to detect - as a separator, similar to _:
if "_" in name:
return "_", name.split("_")
elif "-" in name:
return "-", name.split("-")
else:
# CamelCase splitting...
Then update all_case_variants() to also generate the dash-separated variant.
Summary
The
--preserve-casefeature generates case variants for camelCase and underscore_separated names, but does not handle dash-separated (kebab-case) names likemy-componentorsome-value.Details
There is a TODO at line 688 of
repren.py:# TODO: Could handle dash-separated names as well.The
_split_name()function currently checks for underscores first, then falls back to camelCase splitting. Dash-separated names (common in CSS class names, HTML attributes, CLI flags, file names, and package names) are not recognized — the entire string is treated as one word.Example
With
--preserve-case --from my-component --to new-widget:Current behavior: Only matches literal
my-component→new-widgetExpected behavior: Should also generate:
my-component→new-widget(kebab-case)my_component→new_widget(snake_case)myComponent→newWidget(camelCase)MyComponent→NewWidget(PascalCase)MY_COMPONENT→NEW_WIDGET(SCREAMING_SNAKE)Suggestion
Extend
_split_name()to detect-as a separator, similar to_:Then update
all_case_variants()to also generate the dash-separated variant.