New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Binaries panic when no config file is found #137
Comments
Changed the title because |
We've decided to make the config file not required and also give it a use. for each option that exists within hearth (hearth-root, init, etc) we want to check the config file and the flags. If both are set, the flags get priority. If only one is set, that one is used. If neither are set a default value will be used. If it is not reasonable to have a default value for whatever reason (ex. hearth could not guess where you store the kindling repository) hearth will exit gracefully with message about what is missing. This should make the first time experience for running hearth less painful while still keeping the usefulness of a config file for more advanced users. |
There seems to be a few ways to go about this. This is a problem I feel like should be solved but it sadly seems a bit hard to get good information on it. |
Keeping good error messages is really important. Clap's built in error messages are really helpful. If we handle everything after claps parsing is finished we lose out on the really nice error messages that clap provides. There doesnt seem to be any support in clap itself for this. |
Also found this: https://docs.rs/config/0.13.3/config/ |
This seems really close to what we need: https://crates.io/crates/clap-serde-derive/ |
I like that. Still worried a bit about error messages but I'm honestly not sure if there's much we can do about that. |
going to start trying to implement this now. We can see what the UX looks like when I'm done and decide from there. |
Got it, sounds great. |
By the way, with regards to #174, it seems like the initial issue (binaries panic with no config) and what we're using to solve this with layered config are not closely related. I think that the initial mistake that led to this issue being created was making I think that config file parsing should still be completely removed from the core. If plugins want to accept command line arguments, they should define a configuration structure using The binaries themselves are responsible for including those plugin config structs into their own config structs and then passing those to the plugin constructors. tl;dr layering configs doesn't actually solve the problem blocking #174. What do you think? |
This issue was initially created because it was hard to run hearth for the first time. If the config file wasnt found when running either server or client it would panic. We wanted to make the config file optional and layering it was a pretty natural extension of that. I wasnt aware that the config file loading was done in hearth-core and I agree that it would be a good idea to move that out of there. I dont really get what plugins have to do with things right now. |
Ah, hmmm, the core doesn't actually load the config file, but it DOES require a TOML table in The idea with making the core participate in config loading was that individual plugins could all read from the configuration file (see Basically what I'm saying is that we should completely strip config stuff from the core API. A temporary solution to unblock #174 would be just to pass in an empty TOML table to the runtime builder in the |
got it. How badly do we need #174 right now? This issue has fallen somewhat low on my priorities list so that may be worth doing. |
clap serde derive looks pretty perfect. My one concern is that it is dependent on clap 4. We are currently using clap 3 after #20. In my admittedly limited research it does not seem like there is a reasonable way to get colored output in v4. Honestly though, I think that this may be worth losing out on the coloring for. Thoughts? |
It seems possible to configure it with an unstable feature? may be more hassle than its worth |
@airidaceae want to open a new issue to add layered config with everything we know now WRT |
hearth-server currently panics where there is no config file. it should either make a new empty file (or something with reasonable defaults if we update the config file down the line) or exit cleanly
The text was updated successfully, but these errors were encountered: