You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Make version argument not require other fields and unify error messaging (#302)
## Usage and product changes
Fix an incorrect requirement of `username` and `address` when executing
`console --version`. Additionally, unify the format of error messages
and add colors (e.g., the "error" header is printed in bold red and
argument references are printed in yellow, similar to some of the
existing parsing errors).
## Implementation
### --version
Make all CLI arguments optional. This requires handling `username` and
`address` manually, but it's the most scalable solution (in case we have
more arguments like `--version` that differ from the standard Console
flow).
Considered alternatives:
* use the standard Clap `--version` (not available for us because of the
version overriding mechanism, same as in `typedb` core);
* split CLI into subcommands to have a distinct difference between the
standard execution flow and other commands (I don't like it).
### Error messages
With this change, error messages became more random - some are colored,
while others are not. And this problem extended for specifically parsing
errors.
A less important loss: if both `username` and `address` are missing, we
will only notify about `username` first, and the `address` will be
mentioned only after the initial issue is fixed.
To compensate the stylistic mismatch, we introduce a better
user-friendly error messaging with coloring. Instead of manual coloring
with styling codes, we reuse [clap
structs](https://github.com/clap-rs/clap/blob/4c6fd932cb1860fac450dc7992918a5bde0c6a2b/clap_builder/src/builder/styling.rs#L62)
and formatting approach to make sure that it works consistently for all
error messages, for all operating systems, for all terminal operations
(e.g., redirecting output to a file).
0 commit comments