Function minigrep_test_package_001::run [−][src]
pub fn run(config: Config) -> Result<(), Box<dyn Error>>
Expand description
Given a valid config
of arguments, run the minigrep application.
This is the functional entry-point into the application.
Examples
use std::{env, process}; use minigrep::Config; /// run `minigrep` CLI application fn main() { // try to parse CLI arguments into minigrep config; let config = Config::new(env::args()).unwrap_or_else(|err| { // if fail: convey error and exit eprintln!("Problem parsing arguments: {}", err); process::exit(1); }); // try to run minigrep; convey error and exit if fail if let Err(e) = minigrep::run(config) { eprintln!("Application error: {}", e); process::exit(1); } }
Errors
This function will return an IO error if config.filename
does not exist.
Other errors may also be returned according to std::fs::read_to_string