flagon-io/hello

public

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

Commit

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

g1t agentand Claude Sonnet 5.5committed Parentb2a1a97Browse 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
114114 }
115115
116116 /// The greeting for `name`.
117−pub fn greet(name: &str) -> String {
117+pub fn hail(name: &str) -> String {
118118 greeting_in(name, Lang::En)
119119 }
120120
130130 }
131131
132132 /// The farewell for `name`.
133−pub fn farewell(name: &str) -> String {
133+pub fn part(name: &str) -> String {
134134 let trimmed = name.trim();
135135 let display_name = if trimmed.is_empty() { "world" } else { trimmed };
136136 format!("Goodbye, {display_name}!")
165165
166166 #[test]
167167 fn loud_uses_three_exclamation_marks() {
168− assert_eq!(loud(&greet("Ada")), "Hi, Ada!!!");
168+ assert_eq!(loud(&hail("Ada")), "Hi, Ada!!!");
169169 }
170170
171171 #[test]
290290
291291 #[test]
292292 fn shout_upper_cases_greeting() {
293− assert_eq!(shout(&greet("Ada")), "HI, ADA!");
293+ assert_eq!(shout(&hail("Ada")), "HI, ADA!");
294294 }
295295
296296 #[test]
297297 fn greets_by_name() {
298− assert_eq!(greet("Ada"), "Hi, Ada!");
298+ assert_eq!(hail("Ada"), "Hi, Ada!");
299299 }
300300
301301 #[test]
302302 fn greets_world_with_empty_string() {
303− assert_eq!(greet(""), "Hi, world!");
303+ assert_eq!(hail(""), "Hi, world!");
304304 }
305305
306306 #[test]
307307 fn greets_world_with_whitespace_only() {
308− assert_eq!(greet(" "), "Hi, world!");
308+ assert_eq!(hail(" "), "Hi, world!");
309309 }
310310
311311 #[test]
312312 fn trims_whitespace_from_name() {
313− assert_eq!(greet(" Ada "), "Hi, Ada!");
313+ assert_eq!(hail(" Ada "), "Hi, Ada!");
314314 }
315315
316316 #[test]
317317 fn says_goodbye_by_name() {
318− assert_eq!(farewell("Ada"), "Goodbye, Ada!");
318+ assert_eq!(part("Ada"), "Goodbye, Ada!");
319319 }
320320
321321 #[test]
322322 fn says_goodbye_to_world_when_blank() {
323− assert_eq!(farewell(" "), "Goodbye, world!");
323+ assert_eq!(part(" "), "Goodbye, world!");
324324 }
325325
326326 #[test]
327327 fn farewell_trims_whitespace() {
328− assert_eq!(farewell(" Ada "), "Goodbye, Ada!");
328+ assert_eq!(part(" Ada "), "Goodbye, Ada!");
329329 }
330330 }
+2−2
11 use std::{env, process};
22
3−use hello::{farewell, greeting_in, loud, parse_args, shout};
3+use hello::{greeting_in, loud, parse_args, part, shout};
44
55 fn main() {
66 let options = match parse_args(env::args().skip(1)) {
2929 println!("{line}");
3030 }
3131 if options.bye {
32− println!("{}", farewell(&name));
32+ println!("{}", part(&name));
3333 }
3434 }