json-typedef-infer icon indicating copy to clipboard operation
json-typedef-infer copied to clipboard

Update clap to v4

Open bombsimon opened this issue 2 years ago • 0 comments

This will update clap to v4 and replace the deprecated yaml macro with a struct derive macro.


Thanks for this very useful tool and library. When using this to infer jtd schemas from code and not the actual cli tool I noticed that the clap package uses an old version that depends on yaml-rust which has a known vulnerability.

I thought about putting the cli behind a feature flag but figured it was easier to maintain to just bump clap version. Let me know if you rather use a feature flag or any other approach.

All flags and names are the same but moving to v4 will change two things in the --help output

  • No color support. Afaik there's currently no working color support in v4. I tried setting color = ColorChoice::Always which compiles but doesn't add colored output.
  • The output looks different I did a template but could not make a 1:1 map since v4 groups FLAGS and OPTIONS together. It also handles line breaks of help text differently. Below is the closest template I could make. Since I couldn't map it 1:1 I figured I just use the v4 default output instead.
const HELP_TEMPLATE: &str = "{bin} {version}

USAGE:
    {usage}

OPTIONS:
{options}

ARGS:
{positionals}
";

bombsimon avatar Mar 03 '23 15:03 bombsimon