Hi,
I am currently playing with CLI for my first rust app and what I would like to do is to use clap library in the following way:
main.rs
extern crate clap;
mod cli;
use cli::*;
fn main() {
let options = mycli();
}
cli.rs
use clap::{Arg, App, SubCommand};
pub fn mycli ()-> clap::ArgMatches { // obviously not correct
matches = App::new("tool")
.version("0.01")
.author("Mick Jagger")
.about("My cool tool")
.arg(Arg::with_name("input")
...... // other stuff here
matches
}
bottom line is to outsource all cli parsing and checking into cli.rs (fn mycli()) and once all program logic regarding cli parsing is satisfied the object is returned to my main() function.
How would one achieve this correctly ?
thnx