Expand description
A lightweight Rust crate to help you build awesome tools
It’s designed to be framework-less and relatively simple while providing awesome helper functions for basic tasks that almost any program needs to do. These tasks include reading a config file with multiple paths (user and global), printing with color similar to println!()
and getting user directories cross-platform.
To add it to your dependencies, either run:
cargo add apputils
Or update your Cargo.toml
:
[dependencies]
apputils = "0.1.0"
§Printing with color
use apputils::Colors;
use apputils::paintln;
paintln!(Colors::White, "I'm white.");
paintln!(Colors::Black, "I'm black.");
paintln!(Colors::Yellow, "I'm yellow.");
paintln!(Colors::Red, "I'm red.");
paintln!(Colors::Rgb(35, 170, 242), "I'm #23AAF2.");
§Reading config and data files
An example with wallpaper-dl’s file structure:
use apputils::config::{Cfg, Appdata};
use apputils::dirs::{config_home, data_home};
const APP_NAME: &str = "wallpaper-dl";
const CONFIG_FILE: &str = "config.toml";
const DB_FILE: &str = "wallpapers.toml";
let cfg_path = Cfg::path(APP_NAME, CONFIG_FILE);
let db_path = Appdata::path(APP_NAME, DB_FILE);
assert_eq!(cfg_path, config_home().unwrap().join(APP_NAME).join(CONFIG_FILE)); // e.g. ~/.config/wallpaper-dl/config.toml
assert_eq!(db_path, data_home().unwrap().join(APP_NAME).join(DB_FILE)); // e.g. ~/.local/share/wallpaper-dl/wallpapers.toml
Modules§
- Config file helpers
- User environment wrappers
Macros§
Enums§
- Console Colors