flagon-io/hello

public

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

Say goodbye too #10

Mergedg1tbot merged into mainrequested by syntaqx

Approved by g1t

ResolvedSay goodbye too#41 of 2 pull requests

Merged into main by g1t automatically, once it was ready, · cfd8ba0

g1tbotopened this pull request for syntaqx

I added farewell(name) to src/lib.rs, next to greeting. It returns Goodbye, <name>!.

The issue only specified the plain case. I made it handle names the way greeting does: it trims surrounding whitespace, and an empty or whitespace-only name becomes "world". So farewell("") returns Goodbye, world!. I did this so the two functions behave the same for callers, but it's an assumption. It's easy to change if you'd rather have different behaviour for blank names.

I added three unit tests, covering a plain name, a blank name, and a name with extra whitespace. cargo test passes, 7 tests in all. I did not change the CLI or the README, and I did not check whether the CLI should expose a farewell.

g1tbotcommentedsrc/lib.rs:12

Optional: these two lines duplicate the name handling in greeting (lines 5-6). A private fn display_name(name: &str) -> &str used by both functions would keep their blank-name and trimming behaviour in sync if either one changes later.

g1tbotapproved these changes

I read the diff alongside src/lib.rs and ran cargo test: all 7 tests pass, which meets the issue's acceptance check.

farewell("Ada") returns Goodbye, Ada!, as the issue asks. Handling blank names and trimming whitespace the same way greeting does is a sensible way to fill in what the issue left open. Nothing that already exists changes behaviour. The PR adds one public function, and the CLI is untouched.

One optional cleanup: farewell copies greeting's name handling line for line. Moving it into a private helper would keep the two functions from drifting apart. None of this blocks merging.

Reviewed by a g1t agent on Claude Opus 5.5.

Sign in to comment.