lsd-rs / lsd

The next gen ls command
Apache License 2.0
13.05k stars 425 forks source link

Improve theme error informations #947

Open riquito opened 9 months ago

riquito commented 9 months ago

I couldn't figure out why my local changes to the theme colors definition were not being picked up, so I went to the source. Turned out my yaml file was using some improper fields.

This PR does:

Contrary to before, if a color file definition exists and it cannot be parsed we immediately switch to the default (plus a warning). The previous logic was hiding format errors if there were other file extensions to try.

Some examples of the output (before regular lsd output):

if color.y(a)ml is found, but contains wrong data

Warning: cannot load custom theme. Theme file format invalid. date: unknown field `days-old`, expected one of `hour-old`, `day-old`, `older` at line 18 column 3.

if color.theme is set to "custom" in the config file, but no color.y(a)ml is present

Warning: cannot load custom theme. Cannot read theme file. No such file or directory (os error 2).

Sidenotes:


TODO

muniu-bot[bot] commented 9 months ago

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: riquito

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files: - **[OWNERS](https://github.com/lsd-rs/lsd/blob/master/OWNERS)** Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment
riquito commented 9 months ago

Is there anything I need to do to improve this PR?

zwpaper commented 9 months ago

hi @riquito, sorry for the late reply, the PR looks good and I have started the CI.

thanks for the contribution!

codecov[bot] commented 9 months ago

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (89659e4) 85.76% compared to head (cb9930b) 85.87%. Report is 6 commits behind head on master.

Files Patch % Lines
src/theme.rs 96.15% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #947 +/- ## ========================================== + Coverage 85.76% 85.87% +0.11% ========================================== Files 51 51 Lines 5001 5026 +25 ========================================== + Hits 4289 4316 +27 + Misses 712 710 -2 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.