| 38 | 38 | | pub quiet: bool, |
| 39 | 39 | | /// Whether to end the greeting with three exclamation marks (`--loud`). |
| 40 | 40 | | pub loud: bool, |
| 41 | + | /// Whether to print a goodbye after the greeting (`--bye`). |
| 42 | + | pub bye: bool, |
| 41 | 43 | | } |
| 42 | 44 | | |
| 43 | 45 | | impl Default for Options { |
| ⋯ |
| 50 | 52 | | lang: Lang::En, |
| 51 | 53 | | quiet: false, |
| 52 | 54 | | loud: false, |
| 55 | + | bye: false, |
| 53 | 56 | | } |
| 54 | 57 | | } |
| 55 | 58 | | } |
| ⋯ |
| 77 | 80 | | options.quiet = true; |
| 78 | 81 | | } else if arg == "--loud" || arg == "-L" { |
| 79 | 82 | | options.loud = true; |
| 83 | + | } else if arg == "--bye" { |
| 84 | + | options.bye = true; |
| 80 | 85 | | } else if arg == "--times" { |
| 81 | 86 | | let value = args |
| 82 | 87 | | .next() |
| ⋯ |
| 146 | 151 | | } |
| 147 | 152 | | |
| 148 | 153 | | #[test] |
| 154 | + | fn parse_args_bye() { |
| 155 | + | assert!(parse_args(args(&["--bye", "Ada"])).unwrap().bye); |
| 156 | + | assert!(!parse_args(args(&["Ada"])).unwrap().bye); |
| 157 | + | } |
| 158 | + | |
| 159 | + | #[test] |
| 149 | 160 | | fn parse_args_loud() { |
| 150 | 161 | | assert!(parse_args(args(&["--loud", "Ada"])).unwrap().loud); |
| 151 | 162 | | assert!(parse_args(args(&["-L", "Ada"])).unwrap().loud); |