flagon-io/hello

public

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

Commit

Merge main into wave flag branch

g1t agentand Claude Sonnet 5.5committed Parents69796cbebbaeb2Browse files
3 files+17−130/3 viewed
+4−0
1313 - `--version` flag that prints the crate version and exits
1414 - `--times N` flag that prints the greeting N times (default 1)
1515 - `--lang` option that selects the greeting language (`en` default, `es`, `fr`)
16+
17+### Changed
18+
19+- Renamed the public `greet()` function to `hail()` and `farewell()` to `part()`
+11−11
119119 }
120120
121121 /// The greeting for `name`.
122−pub fn greet(name: &str) -> String {
122+pub fn hail(name: &str) -> String {
123123 greeting_in(name, Lang::En)
124124 }
125125
140140 }
141141
142142 /// The farewell for `name`.
143−pub fn farewell(name: &str) -> String {
143+pub fn part(name: &str) -> String {
144144 let trimmed = name.trim();
145145 let display_name = if trimmed.is_empty() { "world" } else { trimmed };
146146 format!("Goodbye, {display_name}!")
186186
187187 #[test]
188188 fn loud_uses_three_exclamation_marks() {
189− assert_eq!(loud(&greet("Ada")), "Hi, Ada!!!");
189+ assert_eq!(loud(&hail("Ada")), "Hi, Ada!!!");
190190 }
191191
192192 #[test]
311311
312312 #[test]
313313 fn shout_upper_cases_greeting() {
314− assert_eq!(shout(&greet("Ada")), "HI, ADA!");
314+ assert_eq!(shout(&hail("Ada")), "HI, ADA!");
315315 }
316316
317317 #[test]
318318 fn greets_by_name() {
319− assert_eq!(greet("Ada"), "Hi, Ada!");
319+ assert_eq!(hail("Ada"), "Hi, Ada!");
320320 }
321321
322322 #[test]
323323 fn greets_world_with_empty_string() {
324− assert_eq!(greet(""), "Hi, world!");
324+ assert_eq!(hail(""), "Hi, world!");
325325 }
326326
327327 #[test]
328328 fn greets_world_with_whitespace_only() {
329− assert_eq!(greet(" "), "Hi, world!");
329+ assert_eq!(hail(" "), "Hi, world!");
330330 }
331331
332332 #[test]
333333 fn trims_whitespace_from_name() {
334− assert_eq!(greet(" Ada "), "Hi, Ada!");
334+ assert_eq!(hail(" Ada "), "Hi, Ada!");
335335 }
336336
337337 #[test]
338338 fn says_goodbye_by_name() {
339− assert_eq!(farewell("Ada"), "Goodbye, Ada!");
339+ assert_eq!(part("Ada"), "Goodbye, Ada!");
340340 }
341341
342342 #[test]
343343 fn says_goodbye_to_world_when_blank() {
344− assert_eq!(farewell(" "), "Goodbye, world!");
344+ assert_eq!(part(" "), "Goodbye, world!");
345345 }
346346
347347 #[test]
348348 fn farewell_trims_whitespace() {
349− assert_eq!(farewell(" Ada "), "Goodbye, Ada!");
349+ assert_eq!(part(" Ada "), "Goodbye, Ada!");
350350 }
351351 }
+2−2
11 use std::{env, process};
22
3−use hello::{farewell, greeting_in, loud, parse_args, shout, wave};
3+use hello::{greeting_in, loud, parse_args, part, shout, wave};
44
55 fn main() {
66 let options = match parse_args(env::args().skip(1)) {
3232 println!("{}", wave());
3333 }
3434 if options.bye {
35− println!("{}", farewell(&name));
35+ println!("{}", part(&name));
3636 }
3737 }