flagon-io/hello

public

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

Commit

Rename hail() and part() to greet() and farewell()

g1t agentand Claude Sonnet 5.5committed Parent2db41c1Browse files
3 files+16−150/3 viewed
+1−0
1717 ### Changed
1818
1919 - Renamed the public `greet()` function to `hail()` and `farewell()` to `part()`
20+- Renamed `hail()` back to `greet()` and `part()` to `farewell()`
+13−13
141141 }
142142
143143 /// The greeting for `name`.
144−pub fn hail(name: &str) -> String {
144+pub fn greet(name: &str) -> String {
145145 greeting_in(name, Lang::En)
146146 }
147147
162162 }
163163
164164 /// The farewell for `name`.
165−pub fn part(name: &str) -> String {
165+pub fn farewell(name: &str) -> String {
166166 let trimmed = name.trim();
167167 let display_name = if trimmed.is_empty() { "world" } else { trimmed };
168168 format!("Goodbye, {display_name}!")
208208
209209 #[test]
210210 fn loud_uses_three_exclamation_marks() {
211− assert_eq!(loud(&hail("Ada")), "Hi, Ada!!!");
211+ assert_eq!(loud(&greet("Ada")), "Hi, Ada!!!");
212212 }
213213
214214 #[test]
339339
340340 #[test]
341341 fn shout_upper_cases_greeting() {
342− assert_eq!(shout(&hail("Ada")), "HI, ADA!");
342+ assert_eq!(shout(&greet("Ada")), "HI, ADA!");
343343 }
344344
345345 #[test]
346346 fn whisper_lower_cases_and_trails_off() {
347− assert_eq!(whisper(&hail("Ada")), "hi, ada...");
347+ assert_eq!(whisper(&greet("Ada")), "hi, ada...");
348348 assert_eq!(whisper(&greeting_in("Luc", Lang::Fr)), "bonjour, luc...");
349349 }
350350
366366
367367 #[test]
368368 fn reverse_spells_backwards() {
369− assert_eq!(hail(&reverse("Ada")), "Hi, adA!");
369+ assert_eq!(greet(&reverse("Ada")), "Hi, adA!");
370370 }
371371
372372 #[test]
373373 fn greets_by_name() {
374− assert_eq!(hail("Ada"), "Hi, Ada!");
374+ assert_eq!(greet("Ada"), "Hi, Ada!");
375375 }
376376
377377 #[test]
378378 fn greets_world_with_empty_string() {
379− assert_eq!(hail(""), "Hi, world!");
379+ assert_eq!(greet(""), "Hi, world!");
380380 }
381381
382382 #[test]
383383 fn greets_world_with_whitespace_only() {
384− assert_eq!(hail(" "), "Hi, world!");
384+ assert_eq!(greet(" "), "Hi, world!");
385385 }
386386
387387 #[test]
388388 fn trims_whitespace_from_name() {
389− assert_eq!(hail(" Ada "), "Hi, Ada!");
389+ assert_eq!(greet(" Ada "), "Hi, Ada!");
390390 }
391391
392392 #[test]
393393 fn says_goodbye_by_name() {
394− assert_eq!(part("Ada"), "Goodbye, Ada!");
394+ assert_eq!(farewell("Ada"), "Goodbye, Ada!");
395395 }
396396
397397 #[test]
398398 fn says_goodbye_to_world_when_blank() {
399− assert_eq!(part(" "), "Goodbye, world!");
399+ assert_eq!(farewell(" "), "Goodbye, world!");
400400 }
401401
402402 #[test]
403403 fn farewell_trims_whitespace() {
404− assert_eq!(part(" Ada "), "Goodbye, Ada!");
404+ assert_eq!(farewell(" Ada "), "Goodbye, Ada!");
405405 }
406406 }
+2−2
11 use std::{env, process};
22
3−use hello::{greeting_in, loud, parse_args, part, reverse, shout, wave, whisper};
3+use hello::{farewell, greeting_in, loud, parse_args, reverse, shout, wave, whisper};
44
55 fn main() {
66 let options = match parse_args(env::args().skip(1)) {
4747 println!("{}", wave());
4848 }
4949 if options.bye {
50− println!("{}", part(&name));
50+ println!("{}", farewell(&name));
5151 }
5252 }