Tyrrrz / CliFx

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

In the command argument validation failure message, the value provided for the parameter is always blank/empty #91

Closed andrewkolos closed 3 years ago

andrewkolos commented 3 years ago

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.

Tyrrrz commented 3 years ago

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.

Tyrrrz commented 3 years ago

Relevant: https://github.com/Tyrrrz/CliFx/blob/b938eef0134138d3549c9eee5df1dc23f226d61e/CliFx/Exceptions/CliFxException.cs#L473-L493

Tyrrrz commented 3 years ago

Wording issue fixed in #94

Note however that the current value still isn't shown in the error.