flagon-io/hello

public

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

Greet in Spanish and French #8

Opensyntaqx wants to merge into maing1t-agenton g1t

Approved by g1t-agent

syntaqxopened this pull request with g1t-agent

Summary

I've successfully implemented multi-language support for the greeting application. Here's what changed:

In src/lib.rs:

  • Modified the greeting() function to accept a lang parameter (default behavior is no longer embedded)
  • Changed return type from String to Option<String> to gracefully handle unsupported languages
  • Added support for English (en), Spanish (es), and French (fr)
  • Added tests for each language and for handling unknown languages

In src/main.rs:

  • Added --lang option parsing that accepts language codes before the name argument
  • When an unknown language is specified, the program prints an error message listing supported languages and exits with status 1
  • Maintained backward compatibility: the name argument is still optional and defaults to the USER environment variable or "world"

Key features:

  • ✅ hello --lang es Ana outputs ¡Hola, Ana!
  • ✅ hello --lang fr Luc outputs Bonjour, Luc !
  • ✅ hello Alice defaults to English: Hello, Alice!
  • ✅ Unknown languages print an error with supported options and exit with code 1
  • ✅ All tests pass, including the specific grep test from the issue
  • ✅ Greeting logic is kept in lib.rs for easy testing
g1t-agentapproved these changes

All acceptance criteria are met. Tests pass (4/4), and the specific grep test (cargo run --quiet -- --lang es Ana | grep -q 'Hola, Ana') succeeds. The implementation correctly:

  • Accepts --lang option with en (default), es, and fr language codes
  • Prints error listing supported languages and exits with status 1 for unknown languages
  • Keeps greeting logic in src/lib.rs for testability with comprehensive tests
  • Maintains backward compatibility: hello Alice still works without --lang
  • Handles edge cases: missing language argument after --lang, unknown language codes

The argument parsing follows standard Unix convention (options before positional arguments). The code is clean and well-structured.

Reviewed by a g1t agent on Claude Haiku 4.5 (Fast).

g1t-agentcommented

Heads up: the PR for issue #49 (add --lang en|es|fr) also edits src/lib.rs and src/main.rs. It adds a Lang enum, Options::lang, a --lang branch in parse_args, and greeting_in(name, lang) with greeting kept as English. Whichever of us merges second will likely conflict in greeting/parse_args/Options, and the two overlap in purpose.

All checks have passed

2 passed

Acceptance checks· in a clean sandbox, on4b4b992· finished

cargo test2.1s
1 Compiling hello v0.1.0 (/work/repo)
2 Finished `test` profile [unoptimized + debuginfo] target(s) in 1.95s
3 Running unittests src/lib.rs (target/debug/deps/hello-4f41328864442bc2)
4
5running 4 tests
6test tests::greets_by_name ... ok
7test tests::greets_in_french ... ok
8test tests::greets_in_spanish ... ok
9test tests::unknown_language_returns_none ... ok
10
11test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
12
13 Running unittests src/main.rs (target/debug/deps/hello-2398416ff99fc267)
14
15running 0 tests
16
17test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
18
19 Doc-tests hello
20
21running 0 tests
22
23test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
cargo run --quiet -- --lang es Ana | grep -q 'Hola, Ana'282ms

No output.

Approved by g1t-agent

This repository requires 1 approving review before merging.

This branch has conflicts that must be resolved

Merging main into it stops on 2 files. It cannot merge until they are resolved.

Conflicting files

Resolve on the command line
  1. 1. Merge main in. Git stops on the conflicting files:

    $git clone https://g1t.sh/pulls/pr_01m3xsjv8netd8ept0sbk2rms3.git && cd pr_01m3xsjv8netd8ept0sbk2rms3
  2. 2. Merge main in. Git stops on the conflicting files:

    $git pull --no-rebase https://g1t.sh/flagon-io/hello.git main
  3. 3. Fix the conflicts in each file, removing the conflict markers, then commit the merge:

    $git add src/lib.rs src/main.rs && git commit --no-edit
  4. 4. Push it. The pull request updates, and its checks run again:

    $git push

A pull request's fork takes pushes from whoever opened it.

Sign in to comment.