flagon-io/hello

public

Greets people from the command line. The sample repository for g1t.

Commit

Add --both flag

g1t agentand Claude Sonnet 5.5committed Parent2db41c1Browse files
3 files+17−00/3 viewed
+1−0
1515 | `--lang LANG` | Greets in the given language. Supported values are `en`, `es` and `fr`. Defaults to `en`. |
1616 | `--loud`, `-L` | Ends the greeting with `!!!` instead of `!`. |
1717 | `--bye` | Prints `Goodbye, NAME!` after the greeting. |
18+| `--both` | Prints the greeting and `Goodbye, NAME!` on one line. |
1819 | `--wave` | Prints `o/` after the greeting. |
1920 | `--quiet` | Prints no greeting at all. `--version` still prints the version. |
2021
+11−0
4646 pub bye: bool,
4747 /// Whether to print a wave after the greeting (`--wave`).
4848 pub wave: bool,
49+ /// Whether to print the greeting and a goodbye on one line (`--both`).
50+ pub both: bool,
4951 }
5052
5153 impl Default for Options {
6264 loud: false,
6365 bye: false,
6466 wave: false,
67+ both: false,
6568 }
6669 }
6770 }
99102 options.bye = true;
100103 } else if arg == "--wave" {
101104 options.wave = true;
105+ } else if arg == "--both" {
106+ options.both = true;
102107 } else if arg == "--times" {
103108 let value = args
104109 .next()
195200 }
196201
197202 #[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]
198209 fn wave_is_o_slash() {
199210 assert_eq!(wave(), "o/");
200211 }
+5−0
4040 } else {
4141 message
4242 };
43+ let line = if options.both {
44+ format!("{line} {}", part(&name))
45+ } else {
46+ line
47+ };
4348 for _ in 0..options.times {
4449 println!("{line}");
4550 }