| Crates.io | setter |
| lib.rs | setter |
| version | 0.9.2 |
| created_at | 2025-02-11 14:32:33.36742+00 |
| updated_at | 2025-02-25 09:39:31.866514+00 |
| description | A simple configurating tool |
| homepage | https://github.com/TeenCoder159/setter |
| repository | https://github.com/TeenCoder159/setter |
| max_upload_size | |
| id | 1551494 |
| size | 13,539 |
Setter is a project of mine to help me read and write configuration files for my other project, lion AKA lion-cli
Setter can be used in various different places as many projects require a config file for saving things like workspace settings, project settings, currently open files and etc.
See the docs on how to use it
Example:
use setter::config::{read_config, Config, ConfigType};
fn main() {
let mut new_setting = Config {
setting: String::from("foo2"),
mode: String::from("bar2"),
file: String::from("config.toml"),
divider: String::from("[main]"),
};
new_setting.init();
new_setting.setting = String::from("Another Value");
new_setting.write_config();
let value = read_config("Another Value".to_string());
println!(
"Setting value: {}, Set val: {}",
value.unwrap(),
new_setting.mode
);
new_setting.new_divider("[packages]".to_string());
let contents = std::fs::read_to_string(&new_setting.file).expect("Error occured");
println!("{contents}");
match new_setting.config_exists("[main]".to_string()).unwrap() {
ConfigType::Divider => println!("Found a Divider"),
ConfigType::Config => println!("Found a configuration"),
_ => eprintln!("Didn't find anything"),
}
}