ccase icon indicating copy to clipboard operation
ccase copied to clipboard

Fix stdin reading bug and upgrade to convert_case 0.8 from 0.6

Open BernardIgiri opened this issue 7 months ago • 0 comments

This PR addresses multiple issues and enhancements related to CLI behavior and library compatibility:

🐛 Bug Fix

  • Fixes [#2](https://github.com/rutrum/ccase/issues/2): Correctly detects when stdin is piped, allowing input fallback to work reliably in all environments.

🚀 Upgrade

  • Upgrades convert_case from 0.6 to 0.8, which introduces API-breaking changes:
    • The Pattern enum was removed.
    • Case now uses Case<'a> with Custom as a structured variant.
    • Boundary handling API changed slightly.

🛠️ Refactor

  • Introduces UserCase and UserPattern enums as intermediaries:
    • Provides a stable internal abstraction over convert_case changes
    • Uses strum macros to support:
      • CLI parsing via EnumString
      • Help output via Display and VariantNames
      • Iteration via EnumIter
  • CLI help output now mirrors the original style with aligned and styled case/pattern listings.

✅ Tests

  • Made the previously ignored test input_required runnable using an environment flag
  • Added new tests for:
    • Invalid case and pattern inputs (e.g., SNEK, SENT)
    • Pattern application with custom delimiter (-p camel -d ++)
    • Help output includes all expected cases and patterns
    • Input args override stdin when both are present

📌 Compatibility

  • Maintains backwards-compatible CLI behavior for all existing options
  • Prepares for future enhancements by decoupling internal representation from upstream API

BernardIgiri avatar Jun 08 '25 19:06 BernardIgiri