Crates.io | kettle |
lib.rs | kettle |
version | 0.2.2 |
source | src |
created_at | 2020-09-06 18:02:42.0102 |
updated_at | 2021-05-08 13:14:18.114847 |
description | `dirs` and config for platform-specific applications |
homepage | |
repository | https://github.com/asvln/kettle |
max_upload_size | |
id | 285476 |
size | 22,621 |
A library for building applications natively on Linux/Redox/macOS/Windows. It currently provides...
dirs
ini
config filesThis crate utilizes the dirs
crate and re-exports it for easy access.
pub(crate) const THIS_APP: kettle::App = kettle::app("this_APP", None);
fn main() {
let config_dir = THIS_APP.config_dir(); //$HOME/.config/this_APP/
let data_dir = THIS_APP.data_dir(); //$HOME/.local/share/this_APP/
// default config file
THIS_APP.config()
.set("view", Some("horizontal"));
let view = THIS_APP.config()
.get("view");
assert_eq!(view.unwrap(), Some("horizontal".to_string()));
// named config file
THIS_APP.config_file("admin_profiles")
.section("dev") // setting `ini` sections is possible
.set("view", None);
let admin_view = THIS_APP.config_file("admin_profiles")
.section("dev");
.get("view");
assert_eq!(admin_view.unwrap(), None);
}
Licensed under either of Apache License, Version 2.0 or MIT license at your option.