dagit / annelid

Speedrun timer with autosplitter for fxpak/sd2snes
GNU General Public License v3.0
14 stars 4 forks source link

[Request] Setting the websocket host and port to be set via settings and environment variables. #1

Open ChTBoner opened 2 years ago

ChTBoner commented 2 years ago

Hi,

As promised here is the first of a small set of features for bugs/features

As SNI and QUsb2Snes can be ran remotely, I think it would be nice if it were possible to set their host and port from the settings and/or from environment variables.

dagit commented 2 years ago

I'm not a huge fan of env variables, but adding them as command line options and reflecting them in settings.toml should be easy.

I could use some help testing them. It's not a configuration I'm familiar with.

dagit commented 2 years ago

Also, while I could implement this very fast (but testing it would take me longer), I'd also be happy to help you do it if you wanted to practice making contributions.

You'll need to add the setting to AppConfig: https://github.com/dagit/annelid/blob/master/src/main.rs#L53

I've been making everything in there Optional and then providing a reasonable default. You can think of the AppConfig type as a pre-validation input. Once the value has been set from either a) the command line, b) settings.toml, or c) the default, then you can move the decided upon value into LiveSplitCoreRenderer. As for precedent, I usually let things in settings.toml take precedent over the default. And things on the command line take precedent over things in settings.toml.

I hope that helps!

ChTBoner commented 2 years ago

Thanks, I took a look at the code a that's what I figured. I am gonna fork and try

dagit commented 2 years ago

I was doing some annelid work today and I was wondering if you've made any progress or have any questions.

ChTBoner commented 2 years ago

I tried to work on it recently and released my Rust was a bit.... rusty, for lack of a less punny word... I spent some time refreshing my knowledge, but I don't expect to finish this soon.