Crates.io | appcfg |
lib.rs | appcfg |
version | 1.0.1 |
source | src |
created_at | 2024-07-05 07:25:15.913894 |
updated_at | 2024-07-05 07:25:15.913894 |
description | A simple Unix style command line parameter and configuration file parsing library |
homepage | |
repository | |
max_upload_size | |
id | 1292431 |
size | 77,934 |
简单的应用程序命令行设置及配置文件读取库
https://github.com/kivensoft/appconfig_rs
cargo add --git https://github.com/kivensoft/appconfig_rs appconfig
use appconfig;
appconfig::appconfig_define!(app_conf, AppConf,
log_level : String => ["L", "log-level", "LogLevel", "log level(trace/debug/info/warn/error/off)"],
log_file : String => ["F", "log-file", "LogFile", "log filename"],
log_max : String => ["M", "log-max", "LogFileMaxSize", "log file max size (unit: k/m/g)"],
log_async : bool => ["", "log-async", "LogAsync", "enable asynchronous logging"],
no_console : bool => ["", "no-console", "NoConsole", "prohibit outputting logs to the console"],
);
impl Default for AppConf {
fn default() -> Self {
Self {
log_level : String::from("info"),
log_file : String::with_capacity(0),
log_max : String::from("10m"),
log_async : false,
no_console : false,
}
}
}
fn main() {
let ac = AppConf::init();
if !appconfig::parse_args(ac, version).expect("parse args error") {
return;
}
println!("arg log_file = {}", ac.log_file);
}