[GH-ISSUE #18] Default fallback if missing from config #1607

Closed
opened 2026-05-23 03:58:08 +01:00 by JakeStanger · 6 comments
Owner

Originally created by @Kranzes on GitHub (Feb 22, 2022).
Original GitHub issue: https://github.com/JakeStanger/mpd-discord-rpc/issues/18

It would be nice if the program would fallback to the default options if they aren't defined in the config.toml.

For example, a config.toml with this content:

[format]
large_image = ""

Should still work, and not crash the program. The program will then use the default options but replace the large_image option with the one defined in the config file.

Originally created by @Kranzes on GitHub (Feb 22, 2022). Original GitHub issue: https://github.com/JakeStanger/mpd-discord-rpc/issues/18 It would be nice if the program would fallback to the default options if they aren't defined in the `config.toml`. For example, a `config.toml` with this content: ```toml [format] large_image = "" ``` Should still work, and not crash the program. The program will then use the default options but replace the large_image option with the one defined in the config file.
Author
Owner

@JakeStanger commented on GitHub (Feb 22, 2022):

This should already be the case, my bad for not spotting that in the PR that added those new options.

I will try and get that fixed tonight. Edit: Probs gonna push this back a few days, a few work bits have cropped up.

<!-- gh-comment-id:1047958816 --> @JakeStanger commented on GitHub (Feb 22, 2022): This should already be the case, my bad for not spotting that in the PR that added those new options. ~~I will try and get that fixed tonight.~~ Edit: Probs gonna push this back a few days, a few work bits have cropped up.
Author
Owner

@Kranzes commented on GitHub (Feb 22, 2022):

It is not the case only for the new options, the program crashes when just specifying:

 [format]
 details = "$title"
<!-- gh-comment-id:1047963044 --> @Kranzes commented on GitHub (Feb 22, 2022): It is not the case only for the new options, the program crashes when just specifying: ```toml [format] details = "$title" ```
Author
Owner

@JakeStanger commented on GitHub (Feb 22, 2022):

Right yeah, because those ones were guaranteed to exist in a config unless removed. Will sort those ones too 👍

<!-- gh-comment-id:1047973982 --> @JakeStanger commented on GitHub (Feb 22, 2022): Right yeah, because those ones were guaranteed to exist in a config unless removed. Will sort those ones too 👍
Author
Owner

@Kranzes commented on GitHub (Feb 22, 2022):

Don't forget the stuff outside of [format] too.

<!-- gh-comment-id:1047975901 --> @Kranzes commented on GitHub (Feb 22, 2022): Don't forget the stuff outside of `[format]` too.
Author
Owner

@OliverKovacs commented on GitHub (Feb 23, 2022):

@JakeStanger I could take a look at this.

Maybe ditch the system with defaults.rs and make a default config toml and then merge its values to the values loaded from the user's config?

<!-- gh-comment-id:1048324733 --> @OliverKovacs commented on GitHub (Feb 23, 2022): @JakeStanger I could take a look at this. Maybe ditch the system with defaults.rs and make a default config toml and then merge its values to the values loaded from the user's config?
Author
Owner

@JakeStanger commented on GitHub (Feb 23, 2022):

Yeah that'd be great! You could probably keep the defaults struct and just do a better job of merging that into the config struct, but if you think there's a better way go ahead and I'll have a review.

<!-- gh-comment-id:1048326379 --> @JakeStanger commented on GitHub (Feb 23, 2022): Yeah that'd be great! You could probably keep the defaults struct and just do a better job of merging that into the config struct, but if you think there's a better way go ahead and I'll have a review.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
JakeStanger/mpd-discord-rpc#1607
No description provided.