-
-
Notifications
You must be signed in to change notification settings - Fork 61
Description
Is your feature request related to a problem? Please describe.
The error logs are very verbose.
Some parts of it, like the part that's showing which converter function we're talking about, I find is excessively verbose.
Then when there's something wrong with a field you get an output like this:
| goverter-test/pkg/sample.Source
|
| | time.Time
| |
source.CreatedAt.???
target.CreatedAt.wall
| | |
| | | uint64
| |
| | time.Time
|
| goverter-test/pkg/sample.Target
^it took me quite long before I understood that the pipe characters are arrows pointing to the fields. For a long time I thought it was a weird tree, but for some reason some parts were not indented.
Then I find it excessive to show absolute paths. I don't think you'd lose a bunch of info from changing that to relative paths.
The output could also benefit a lot from a splash of colors :)
Describe the solution you'd like
Instead of showing func (goverter-test/pkg/sample.Converter).ConvertFoo(source goverter-test/pkg/sample.Source, timeFormat string) goverter-test/pkg/sample.Target, I suggest just showing a verbatim output of the input code instead: ConvertFoo(source Source, timeFormat string) Target. I believe getting access to the AST tokens should be possible, right?
Also using some box-drawing characters would be nice: ╭╰─┴┬│
I've made a mockup for inspiration, where I tried to mimic the color theme used in the docs.
Before
After
Source code
�[41m Error while creating converter method: �[0m
�[90m ╭── �[90;3mfile: ./sample.go�[0m
�[90m … │�[0m
�[90m 7 │�[0m �[90m// goverter:converter�[0m
�[90m 8 │�[0m �[91mtype�[0m �[35mConverter�[0m �[91minterface�[0m {
�[90m … │�[0m
�[90m13 │�[0m �[90m// goverter:map Name | strings.ToUpper�[0m
�[90m14 │�[0m �[90m// goverter:context timeFormat�[0m
�[90m15 │�[0m �[0mConvertFoo�[0m(�[33msource�[0m �[35mSource�[0m, �[33mtimeFormat�[0m �[91mstring�[0m) �[35mTarget�[0m
�[90m … │�[0m
�[90m18 │�[0m }
�[48;5;88m[source]�[0m �[90mgoverter-test/pkg/�[0m�[35msample�[0m.�[35mSource�[0m
�[48;5;20m[context]�[0m �[91mstring�[0m
�[48;5;22m[target]�[0m �[90mgoverter-test/pkg/�[0m�[35msample�[0m.�[35mTarget�[0m
�[38;5;88m ╭──�[0m �[90mgoverter-test/pkg/�[0m�[35msample�[0m.�[35mSource�[0m
�[38;5;88m │ ╭──�[0m �[35mtime�[0m.�[35mTime�[0m
�[38;5;88m───┴── ────┴────�[0m
�[48;5;88msource�[0m.CreatedAt.�[41m???�[0m
�[48;5;22mtarget�[0m.CreatedAt.wall
�[38;5;22m───┬── ────┬──── ──┬─�[0m
�[38;5;22m │ │ ╰──�[0m �[91muint64�[0m
�[38;5;22m │ ╰──�[0m �[35mtime�[0m.�[35mTime�[0m
�[38;5;22m ╰──�[0m �[90mgoverter-test/pkg/�[0m�[35msample�[0m.�[35mTarget�[0m
�[31mCannot set value for unexported field "wall".�[0m
See �[36mhttps://goverter.jmattheis.de/guide/unexported-field�[0m
Sample code block of how it would look in GitHub when uncolored
Error while creating converter method:
╭── file: ./sample.go
… │
7 │ // goverter:converter
8 │ type Converter interface {
… │
13 │ // goverter:map Name | strings.ToUpper
14 │ // goverter:context timeFormat
15 │ ConvertFoo(source Source, timeFormat string) Target
… │
18 │ }
[source] goverter-test/pkg/sample.Source
[context] string
[target] goverter-test/pkg/sample.Target
╭── goverter-test/pkg/sample.Source
│ ╭── time.Time
───┴── ────┴────
source.CreatedAt.???
target.CreatedAt.wall
───┬── ────┬──── ──┬─
│ │ ╰── uint64
│ ╰── time.Time
╰── goverter-test/pkg/sample.Target
Cannot set value for unexported field "wall".
See https://goverter.jmattheis.de/guide/unexported-field
(If you want I can create more mockups for other error types. I'd probably be interested in trying to help contribute this too)
The colored output part should respect your terminal's color support, which should be easy enough by using a library like https://github.com/charmbracelet/lipgloss. Also there should be a flag like --color=always or --force-colors to enable colored output even when doing things like piping the output or when running inside GitHub Actions.
Describe alternatives you've considered
nothing comes to mind

