commandline icon indicating copy to clipboard operation
commandline copied to clipboard

Support fake results

Open themacguffinman opened this issue 9 years ago • 2 comments

Right now it's impossible to raise my own parser errors because all classes relating to the error system are sealed with internal constructors.

This snippet from HelpTextTests is completely inaccessible:

    var fakeResult = new NotParsed<object>(
                TypeInfo.Create(typeof(NullInstance)),
                new Error[]
                    {
                        new BadFormatTokenError("badtoken"),
                        new MissingValueOptionError(new NameInfo("x", "switch")),
                        new UnknownOptionError("unknown"),
                        new MissingRequiredOptionError(new NameInfo("", "missing")),
                        new SequenceOutOfRangeError(new NameInfo("s", "sequence")),
                        new NoVerbSelectedError(),
                        new BadVerbSelectedError("badverb"),
                        new HelpRequestedError(), // should be ignored
                        new HelpVerbRequestedError(null, null, false) // should be ignored 
                    });

Please publicly expose the error system to support custom error management.

themacguffinman avatar Aug 25 '16 06:08 themacguffinman

Can you share some scenarios where you might use custom error management?

nemec avatar Nov 05 '16 07:11 nemec

@nemec @gsscoder Validation. I might want to validate the parsing results with some complex logic, or at the very least use a regular expression on some parameter to check if it is valid or not. The error should then be printd in the exact same fashion as built-in errors for consistency.

ZimM-LostPolygon avatar Mar 18 '17 18:03 ZimM-LostPolygon