#dirs #ini #xdg #config #app

yanked kettle

dirs and config for platform-specific applications

0.2.2 May 8, 2021
0.2.1 May 4, 2021
0.2.0 May 4, 2021
0.1.1 Jan 3, 2021
0.1.0 Sep 6, 2020

#5 in #dirs

MIT license

11KB
175 lines

crates.io API documentation actively developed License: MIT/Apache-2.0

kettle

A library for building applications natively on Linux/Redox/macOS/Windows. It currently provides...

  • app-specific dirs
  • easy ini config files

This crate utilizes the dirs crate and re-exports it for easy access.

Usage

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);
}

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.

Dependencies

~1.8–2.7MB
~47K SLoC