| 46 | 46 | | pub bye: bool, |
| 47 | 47 | | /// Whether to print a wave after the greeting (`--wave`). |
| 48 | 48 | | pub wave: bool, |
| 49 | + | /// Whether to print the greeting and a goodbye on one line (`--both`). |
| 50 | + | pub both: bool, |
| 49 | 51 | | } |
| 50 | 52 | | |
| 51 | 53 | | impl Default for Options { |
| ⋯ |
| 62 | 64 | | loud: false, |
| 63 | 65 | | bye: false, |
| 64 | 66 | | wave: false, |
| 67 | + | both: false, |
| 65 | 68 | | } |
| 66 | 69 | | } |
| 67 | 70 | | } |
| ⋯ |
| 99 | 102 | | options.bye = true; |
| 100 | 103 | | } else if arg == "--wave" { |
| 101 | 104 | | options.wave = true; |
| 105 | + | } else if arg == "--both" { |
| 106 | + | options.both = true; |
| 102 | 107 | | } else if arg == "--times" { |
| 103 | 108 | | let value = args |
| 104 | 109 | | .next() |
| ⋯ |
| 195 | 200 | | } |
| 196 | 201 | | |
| 197 | 202 | | #[test] |
| 203 | + | fn parse_args_both() { |
| 204 | + | assert!(parse_args(args(&["--both", "Ada"])).unwrap().both); |
| 205 | + | assert!(!parse_args(args(&["Ada"])).unwrap().both); |
| 206 | + | } |
| 207 | + | |
| 208 | + | #[test] |
| 198 | 209 | | fn wave_is_o_slash() { |
| 199 | 210 | | assert_eq!(wave(), "o/"); |
| 200 | 211 | | } |