flagon-io/hello

public

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

Add a --lang option (en, es, fr) to the greeter #53

Mergedg1tbot merged into maing1t-agenton g1t

Approved by g1t-agent

ResolvedAdd a --lang option (en, es, fr) to the greeter#49

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

syntaqxopened this pull request with g1t-agent

The hello CLI now takes --lang <code> with en (the default), es and fr. cargo test passes, and cargo run -- --lang es Ana prints ¡Hola, Ana!. cargo run -- --lang fr Luc prints Bonjour, Luc !.

In src/lib.rs I added a Lang enum with a Lang::parse helper, plus an Options::lang field that defaults to English. parse_args handles --lang the way it handles --times, and its doc comment is updated. A missing value returns --lang requires a value. An unknown value returns --lang value must be one of en, es, fr, got "de".

greeting_in(name, lang) is new and greeting(name) now calls it with English, so existing callers are unchanged. Trimming and the world fallback for blank names apply in every language, and shout is untouched. src/main.rs builds the message with the selected language.

I added unit tests in src/lib.rs and integration tests in tests/cli.rs. They cover es, fr, default en, an unknown language (exit code 2, stderr names en, es, fr) and a missing value. I did not edit README.md or CHANGELOG.md.

Open PRs #7 and #8 (issue #2, Spanish and French greetings) change the same parts of src/lib.rs and src/main.rs, so whichever lands second will probably conflict. I commented on both to say so. I did not try merging against them.

syntaqxmarked this ready for review·
g1tbotrequested a review from g1t-agent·
g1t-agentapproved these changes

Read the diff and ran cargo test; all unit and integration tests pass. The change matches issue #49. Lang and Lang::parse are added. parse_args handles --lang like --times, with the exact error messages the issue specifies. greeting_in is added and greeting delegates to it with English. Trimming and the world fallback apply in every language. main.rs uses the selected language and shout is unchanged. README.md and CHANGELOG.md are untouched. Tests cover es, fr, default en, an unknown language (exit 2, stderr names en, es, fr) and a missing value. I found no problems. The overlap with open PRs #7 and #8 is already noted in the PR.

Reviewed by a g1t agent on Claude Sonnet 5.5.

g1tbotadded this to the merge queue·
g1tbotmerged this·

Sign in to comment.