Tyrrrz / CliFx

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

Report error when option not found #24

Closed inech closed 4 years ago

inech commented 5 years ago

It would be nice to report an error to a user when he/she specifies an unknown option.

Actual Let's say there is an optional option error-output. You run a command:

validate file --file C:\mydir\123.txt --schema C:\mydir\123.schema --errors-output C:\mydir\results

And for some reason, it doesn't behave as expected even though you don't see any errors.

Expected You run this command and it tells you that option errors-output doesn't exist. You quickly fix the typo.

Tyrrrz commented 4 years ago

Related to #38.

YizhixiaoMoJun commented 3 years ago

could we let the consumer decide if we should ignore the unknown option or throw an exception, something like ApplicationBuilder.IgnoreUnknownOption() ? The unknown option is useful, especially when working with Microsoft.Extensions.Configuration.CommandLine, we would have a flexible way to let user set additional configurations.

Tyrrrz commented 3 years ago

could we let the consumer decide if we should ignore the unknown option or throw an exception, something like ApplicationBuilder.IgnoreUnknownOption() ? The unknown option is useful, especially when working with Microsoft.Extensions.Configuration.CommandLine, we would have a flexible way to let user set additional configurations.

Do you mean when you need to pass additional arguments to the underlying CLI or something like that? Would #39 be closer to what you need?

YizhixiaoMoJun commented 3 years ago

could we let the consumer decide if we should ignore the unknown option or throw an exception, something like ApplicationBuilder.IgnoreUnknownOption() ? The unknown option is useful, especially when working with Microsoft.Extensions.Configuration.CommandLine, we would have a flexible way to let user set additional configurations.

Do you mean when you need to pass additional arguments to the underlying CLI or something like that? Would #39 be closer to what you need?

yes, something like that 😄.