flagon-io/hello

public

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

Add a --reverse flag #85

Mergedg1t merged into maing1t-agenton g1t

Approved by g1t-agent

ResolvedAdd a --reverse flag#84

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

syntaqxopened this pull request with g1t-agent

I added a --reverse flag. hello --reverse Ada prints Hi, adA!, and with no name it reverses whatever name would have been used, such as USER or world. All tests pass under cargo test.

The reversal happens in main before the greeting is built, so --bye also uses the reversed name. The issue didn't say whether the goodbye should be reversed, so I chose to reverse it too.

I added a reverse function, an option field and parser arm in src/lib.rs, the one-line call in src/main.rs, and a README row for the flag. The tests cover the parser and the Ada to adA example. The README row sits just above --version.

The edits in src/lib.rs, src/main.rs and the README are small, so they should merge cleanly with the in-progress Spanish/French pull requests #7 and #8, which touch the same files.

I couldn't run cargo fmt because rustfmt isn't installed here, so formatting is unchecked. I didn't run the binary by hand, only the tests.

syntaqxmarked this ready for review·
g1tsent g1t-agent back to fix the failed workflows·
g1trequested a review from g1t-agent·
g1t-agentcommentedsrc/main.rs:25

Because the name is reversed here, --bye also prints the reversed name. This is fine, but add a test in tests/cli.rs for --reverse (and --reverse --bye) so the behaviour is pinned down.

g1t-agentapproved these changes

Ran cargo test (all pass) and the binary by hand: hello --reverse Ada prints Hi, adA!, and --reverse --bye Ada prints Goodbye, adA!. The parser arm and the default-name path (reversal happens after the USER/world fallback) are correct, and chars().rev() is fine for ordinary names. The README row is present, so the CI README-flag check should pass.

Non-blocking notes:

  • The new tests only cover parse_args and reverse. tests/cli.rs has no end-to-end case for hello --reverse Ada or the default-name case, which is where the real behaviour lives (the reversal is in main).
  • The parse_args doc comment and CHANGELOG don't list --reverse (they also omit some earlier flags, so this is consistent with existing practice).
  • Reversing the --bye goodbye is a reasonable choice, but it is a behaviour decision the issue left open, so a maintainer may want to confirm it.
  • The PR description's claim that it merges cleanly with #7/#8 is unverified, and I did not check it. rustfmt is also not installed here, so formatting is unchecked, but the code looks rustfmt-style.

Reviewed by a g1t agent on Claude Sonnet 5.5.

g1tadded this to the merge queue·
g1tmerged this·

Sign in to comment.