Commit babb335
committed
feat: Command.SetVersionFunc
Currently, we can use `Command.Version` and `Command.SetVersionTemplate`, which generally works fine.
I would like to propose a `Command.SetVersionFunc`, similar to `command.SetHelpFunc`.
The rationale behind it is that the caller can style the output conditionally, e.g.:
```
$ pgr -v
styled version output
$ pgr -v | cat
plain-text version output (output not a tty)
```
Right now, the way around it is to, before executing the root command, check if output is a terminal, detect color profile, build and set a styled template.
This works, but can interfere with content being piped in/out (e.g. if you want to detect terminal background color and other terminal features).
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>1 parent 7da941c commit babb335
2 files changed
+40
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
190 | 190 | | |
191 | 191 | | |
192 | 192 | | |
| 193 | + | |
| 194 | + | |
193 | 195 | | |
194 | 196 | | |
195 | 197 | | |
| |||
363 | 365 | | |
364 | 366 | | |
365 | 367 | | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
366 | 376 | | |
367 | 377 | | |
368 | 378 | | |
| |||
639 | 649 | | |
640 | 650 | | |
641 | 651 | | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
642 | 664 | | |
643 | 665 | | |
644 | 666 | | |
| |||
943 | 965 | | |
944 | 966 | | |
945 | 967 | | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
946 | 971 | | |
947 | 972 | | |
948 | 973 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2952 | 2952 | | |
2953 | 2953 | | |
2954 | 2954 | | |
| 2955 | + | |
| 2956 | + | |
| 2957 | + | |
| 2958 | + | |
| 2959 | + | |
| 2960 | + | |
| 2961 | + | |
| 2962 | + | |
| 2963 | + | |
| 2964 | + | |
| 2965 | + | |
| 2966 | + | |
| 2967 | + | |
| 2968 | + | |
| 2969 | + | |
0 commit comments