Tyrrrz / CliFx

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

Allow custom formatting of output #23

Closed thorhj closed 4 years ago

thorhj commented 5 years ago

First of all, nice framework :)

I think it would be nice to allow custom formatting of output that is currently fixed. Output that I have seen so far (not an extensive list):

Tyrrrz commented 5 years ago

Hi, thank you. Do you have a use case for this? Ideally we would want to have error messages so good that they won't need to be replaced, so if you have a suggestion how it should look, I'm all ears. Technically it's not too hard to implement but I'd like to figure out what are the pros/cons.

thorhj commented 5 years ago

I have three things that bother me right now:

  1. I think the argument type mismatch is too vague; it does not REALLY tell the user what went wrong. It tells the technical description of what went wrong (could not convert) but I think it should instead inform the user what was expected, e.g. The value 'abc' for option 'id' is invalid; it must be an integer.
  2. I want to wrap the CLI in a batch script so I can call it using myprogram command subcommand args instead of dotnet MyProgram.dll command subcommand args. The help text uses the latter format which I cannot change.
  3. I don't like the background color on the headers (Usage, Options, etc.), but that is a more of a subjective matter 😉
Tyrrrz commented 5 years ago
  1. Fair enough. The type names are kinda generic because you can use options of any time, but we can make special cases for base types.
  2. You can change it using .WithExecutableName() on CliApplicationBuilder. It's impossible to know that it was launched from a batch file unfortunately.
  3. The colors actually look different in different terminals. I assume you don't like how it looks in cmd?
thorhj commented 5 years ago

You can change it using .WithExecutableName() on CliApplicationBuilder. It's impossible to know that it was launched from a batch file unfortunately.

Nice, exactly what I was looking for (it is UseExecutibleName() actually).

The colors actually look different in different terminals. I assume you don't like how it looks in cmd?

I use Cmder with a custom color scheme, but it has more to do with me not being a fan of background colors I guess.

I think the standard outputs that you have made are generally fine, but it would be nice to be able to customize them to one's own needs. I am not suggesting it is something you have to do as a consumer, but it would be nice to have the option.

Tyrrrz commented 5 years ago

Nice, exactly what I was looking for (it is UseExecutibleName() actually).

Oops.

Tyrrrz commented 4 years ago

Removed the background color on headers.

Also changed the errors in case of conversion failure, but they're still a bit technical.

Tyrrrz commented 4 years ago

Updated the error messages again. I'll be continually improving them to make them sound better. Closing this for now as I don't think I will be adding custom formatting.