Module hm::config

source ·
Expand description

Define our Config and Worker. Implement how to take the config.toml and turn it into a Config { files: Vec<ManagedObject> }. Describes the Worker object, which is how we communicate back to our main() thread about how our task is going.

Structs

Represents just the file config.toml and contains a vector of things that shall become ManagedObjects.
We’re a super-set of all the kinds of ManagedObjects we can be. Just don’t use the fields you don’t wanna use. A simple ManagedObject is a name, source, destination, and method (currently only symlink). The simple ManagedObject would just be symlinked to its destination. Complex ManagedObjects include solutions, which are executed scripts.
Allow us to communicate meaningfully back to main() thread.

Enums

Functions

Open our config file and read the entire contents into hopefully valid toml. Either we gucci and return back a Config made of toml, or we explain what went wrong with the toml Err.
This takes our file/task array and turns them into ManagedObjects, to be stuffed into the Config.
Windows or Linux? If Linux, let’s determine our distro, because package managers and stuff.
Make sure $XDG_CONFIG_DIR exists. On Linux and similar this is /home/<username>/.config; macOS /Users/<username>/.config, Windows C:\Users\<username>\.config