kettle

Crates.iokettle
lib.rskettle
version0.2.2
sourcesrc
created_at2020-09-06 18:02:42.0102
updated_at2021-05-08 13:14:18.114847
description`dirs` and config for platform-specific applications
homepage
repositoryhttps://github.com/asvln/kettle
max_upload_size
id285476
size22,621
(asvln)

documentation

https://docs.rs/kettle/

README

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.

Commit count: 0

cargo fmt