summaryrefslogtreecommitdiffstats
path: root/src/doc/book/listings/ch12-an-io-project/listing-12-14/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/doc/book/listings/ch12-an-io-project/listing-12-14/src/main.rs')
-rw-r--r--src/doc/book/listings/ch12-an-io-project/listing-12-14/src/main.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/doc/book/listings/ch12-an-io-project/listing-12-14/src/main.rs b/src/doc/book/listings/ch12-an-io-project/listing-12-14/src/main.rs
new file mode 100644
index 000000000..3b76009b5
--- /dev/null
+++ b/src/doc/book/listings/ch12-an-io-project/listing-12-14/src/main.rs
@@ -0,0 +1,29 @@
+// ANCHOR: here
+use std::env;
+use std::process;
+
+use minigrep::Config;
+
+fn main() {
+ // --snip--
+ // ANCHOR_END: here
+ let args: Vec<String> = env::args().collect();
+
+ let config = Config::build(&args).unwrap_or_else(|err| {
+ println!("Problem parsing arguments: {err}");
+ process::exit(1);
+ });
+
+ println!("Searching for {}", config.query);
+ println!("In file {}", config.file_path);
+
+ // ANCHOR: here
+ if let Err(e) = minigrep::run(config) {
+ // --snip--
+ // ANCHOR_END: here
+ println!("Application error: {e}");
+ process::exit(1);
+ // ANCHOR: here
+ }
+}
+// ANCHOR_END: here