I'd like to create a command line that utilizes clap to parse input. The best I can come up with is a loop that asks the user for input, breaks it up with a regex and builds a Vec which it somehow passes to
loop {
// Print command prompt and get command
print!("> "); io::stdout().flush().expect("Couldn't flush stdout");
let mut input = String::new(); // Take user input (to be parsed as clap args)
io::stdin().read_line(&mut input).expect("Error reading input.");
let args = WORD.captures_iter(&input)
.map(|cap| cap.get(1).or(cap.get(2)).unwrap().as_str())
.collect::<Vec<&str>>();
let matches = App::new("MyApp")
// ... Process Clap args/subcommands
.get_matches(args); //match arguments from CLI args variable
}
Basically, I'm wondering if there is a way to direct Clap to use a pre-given list of arguments?