diff --git a/src/SUMMARY.md b/src/SUMMARY.md index 06a3ab8dd..a61d2c99c 100644 --- a/src/SUMMARY.md +++ b/src/SUMMARY.md @@ -55,7 +55,7 @@ - [Running tests](ch11-02-running-tests.md) - [Test Organization](ch11-03-test-organization.md) -- [I/O]() +- [An I/O Project](ch12-00-an-io-project.md) - [`Read` & `Write`]() - [`std::fs`]() - [`std::path`]() diff --git a/src/ch12-00-an-io-project.md b/src/ch12-00-an-io-project.md new file mode 100644 index 000000000..548a8f8af --- /dev/null +++ b/src/ch12-00-an-io-project.md @@ -0,0 +1,35 @@ +# An I/O Project + +`cargo new --bin greprs` + +Project requirements: + +- Take a search string and a filename as command line arguments +- Read the file +- Find lines in the file that contain the search string +- Print out those lines + +In order to do a good job, we will: + +- Organize code (using what we learned in modules, ch 7) +- Use strings (collections, ch 8) +- Handle errors (ch 9) +- Have tests (ch 11) + +Generics/traits/lifetimes? + +## Command line arguments + +* Use `std::env::args()` + +Filename: src/main.rs + +```rust +use std::env; + +fn main() { + let args: Vec = env::args().collect(); + println!("{:?}", args); +} +``` +