Tyrrrz / CliFx

Class-first framework for building command-line interfaces
MIT License
1.48k stars 60 forks source link

Print help text on specific exceptions #16

Closed Tyrrrz closed 4 years ago

Tyrrrz commented 5 years ago

Exceptions related to user input should probably trigger help automatically so that besides being told "you didn't specify option --required" the user will also be shown what that option actually is.

Possibly also extend CommandException so that it's possible to request help when throwing that exception.

domn1995 commented 4 years ago

Related to #48

domn1995 commented 4 years ago

At first look, it looks like we want to augment all the new CliFxException(...)s in the "End-user-facing exceptions" partial section of CliFxException with the showHelp parameter of #49 to fulfill this feature.

https://github.com/Tyrrrz/CliFx/blob/1dab27de551c8fcb5abd2656b5372c0091a77eb5/CliFx/Exceptions/CliFxException.cs#L268-L366

@Tyrrrz, do you agree? Are there any other locations where we might need to show help as a result of handling an error?

Tyrrrz commented 4 years ago

Yeah, that's right. Seems like all those exceptions could be accompanied with help text.

domn1995 commented 4 years ago

Cool, I'll get you a PR in the near future :)

Tyrrrz commented 4 years ago

Go ahead :)