Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.
| Add --times N flag that prints the greeting N times | 1 | use std::{env, process}; |
| Greet people from the command line | 2 | |
| Merge main into wave flag branch | 3 | use hello::{greeting_in, loud, parse_args, part, shout, wave}; |
| Greet people from the command line | 4 | |
| 5 | fn main() { | |
| Add --times N flag that prints the greeting N times | 6 | let options = match parse_args(env::args().skip(1)) { |
| 7 | Ok(options) => options, | |
| 8 | Err(message) => { | |
| 9 | eprintln!("error: {message}"); | |
| 10 | process::exit(2); | |
| 11 | } | |
| 12 | }; | |
| Add --version flag that prints the crate version and exits | 13 | if options.version { |
| 14 | println!("{}", env!("CARGO_PKG_VERSION")); | |
| 15 | return; | |
| 16 | } | |
| Add --quiet flag that prints nothing | 17 | if options.quiet { |
| 18 | return; | |
| 19 | } | |
| Greet people from the command line | 20 | // The name given, or whoever is signed in. |
| Add --shout flag that upper-cases the greeting | 21 | let name = options |
| Extract argument parsing into parse_args in lib.rs | 22 | .name |
| Greet people from the command line | 23 | .or_else(|| env::var("USER").ok()) |
| 24 | .unwrap_or_else(|| "world".to_owned()); | |
| Merge #53: Add a --lang option (en, es, fr) to the greeter | 25 | let message = greeting_in(&name, options.lang); |
| Add CI workflow for formatting, lints and tests | 26 | let message = if options.loud { |
| 27 | loud(&message) | |
| 28 | } else { | |
| 29 | message | |
| 30 | }; | |
| 31 | let line = if options.shout { | |
| 32 | shout(&message) | |
| 33 | } else { | |
| 34 | message | |
| 35 | }; | |
| Add --times N flag that prints the greeting N times | 36 | for _ in 0..options.times { |
| 37 | println!("{line}"); | |
| 38 | } | |
| Add --wave flag that prints o/ after the greeting | 39 | if options.wave { |
| 40 | println!("{}", wave()); | |
| 41 | } | |
| Merge #64: Add a --bye flag | 42 | if options.bye { |
| Merge main into wave flag branch | 43 | println!("{}", part(&name)); |
| Merge #64: Add a --bye flag | 44 | } |
| Greet people from the command line | 45 | } |
This file's history is long; its oldest lines are credited to the oldest commit read.