========================================
wd_run supports command line parsing and configuration file parsing. It is mainly achieved through the method of registering callbacks.
The following configuration file parsing formats are supported: - [x] json - [x] yaml - [x] json - [ ] http (coding)
rust
[dependencies]
wd_run = "0.1"
Run the following code and the command line
bash
//help
cargo run -- -h
//run
cargo run -- run
```rust
use wdrun::{CmdInfo, KEARGS, ExecManager,Context};
use std::collections::HashMap;
use std::sync::Arc;
async fn main() { let mut em = ExecManager::new().await; let cr = CoreRun{}; em.registered(cr.clone(), CoreRun::getflagdefault()); em.registered(cr, CoreRun::getflagexit()); em.run().await.unwrap(); }
pub struct CoreRun {
}
impl CoreRun {
//获取命令行参数参数设置
pub fn getflagdefault() -> CmdInfo {
let mut ci = CmdInfo::new("run", "", "start run core");
ci.setflag("-c", "./src/util/conf/config.toml", "config file path");
ci
}
pub fn getflags(ctx: Arc
impl wdrun::AsyncEvent for CoreRun {
async fn handle(&self, ctx: Arc
```rust
pub struct Config { pub log: i32, pub server: String, pub stream: String, }
fn testconfig () { let conf:Config = wdrun::load_config("./src/util/conf/config.toml").unwrap(); println!("{:?}",conf) } ```
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.