In the command argument validation failure message, the value provided for the parameter is always blank/empty
andrewkolos opened this issue · 3 comments
When a validator for a command argument returns an error result, the console emits a message that gives the value it was provided for that parameter as well as an error message provided by the validator. However, the app lists the value provided as blank. See the first line of the output below.
Command:
book add ijwef --author asbeb
Output:
Value provided for parameter <title>:
Hello I am an error
Description
Add a book to the library.
Usage
dotnet CliFx.Demo.dll book add <title> --author <value> [options]
Parameters
* title Book title.
Options
* -a|--author Book author.
-p|--published Book publish date. Default: "07/14/1954 19:24:40 +00:00".
-n|--isbn Book ISBN. Default: "905-83-85944-51-7".
-h|--help Shows help text.
You can demo the issue by cloning this fork and running the debug for the CliFx.Demo project.
It looks like the error message is incorrect and was accidentally truncated. It's supposed to say Value provided for parameter <title> is invalid:
with the following line being the reason. It was never meant to actually print the value. That said, it may be a good idea to align this if other errors do print it.
Relevant:
CliFx/CliFx/Exceptions/CliFxException.cs
Lines 473 to 493 in b938eef