kettle
kettle
is a small library which provides simple cross-platform access to project specific config
, cache
, data
, etc. directories for applications running on Linux/macOS/Windows. It also includes an ini
based config file which can be easily used for application settings.
This crate utilizes the dirs
crate and re-exports it for easy access to non-application specific directories.
Usage
use kettle::Project;
pub const APP: Project = Project::init("app_name", None);
fn main() {
let config_dir = APP.config_dir();
let cache_dir = APP.cache_dir();
let data_dir = APP.data_dir();
APP.config_set("default_view", Some("vertical"));
APP.config_section_set("admin", "default_view", Some("horizontal"));
APP.config_set("key with spaces", None);
let default_view = APP.config_get("default_view").unwrap();
let admin_view = APP.config_section_get("admin", "default_view").unwrap();
let spaces_key = APP.config_get("key with spaces").unwrap();
assert_eq!(default_view, Some("vertical".to_string()));
assert_eq!(admin_view, Some("horizontal".to_string()));
assert_eq!(spaces_key, None);
}
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.