cobra icon indicating copy to clipboard operation
cobra copied to clipboard

Add new type to represent validating required flag error

Open sivchari opened this issue 6 months ago • 3 comments
trafficstars

Currently, when we met the ValidateRequiredField error, we should compare as a raw string. This proposal aims to compare by using errors.Is/As and csting from interface to the type.

sivchari avatar Apr 29 '25 05:04 sivchari

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Apr 29 '25 05:04 CLAassistant

This feature was also implemented by PR #2266, and that PR also includes an error type added by an older PR, #2178 (CC @mvo5).

Seeing as how we have three different PRs aiming to achieve the same goal of making it possible to determine the type of and unwrap errors generated by Cobra, I think it would be a good idea to focus our combined efforts around a single implementation.

I might be a bit biased as the author of #2266, but that one covers pretty much every user-caused error type that Cobra can return. For what it's worth mentioning as well, a similar effort was made to add error structs to spf13/pflag. It would be great to have cobra fully support them as well.

eth-p avatar May 05 '25 00:05 eth-p

Thanks for cross referencing things.

I saw the previous one @eth-p

Then I saw this one, I thought it was from the same author, that had closed then reopened a new PR

I have already shared my concerns with the implementation in this PR

ccoVeille avatar May 05 '25 12:05 ccoVeille