Skip to content

fix(_mnn): remove false claims from help text - #117

Merged
michen00 merged 3 commits into
mainfrom
fix/mnn-help-text
Sep 23, 2026
Merged

michen00 merged 3 commits into
mainfrom
fix/mnn-help-text

Conversation

@michen00

Copy link
Copy Markdown
Owner

Run as _mnn, --help described a command that doesn't work:

$ _mnn --help
...
Copies em dash (Unicode U+2014) to the system clipboard.
...
Examples:
  _mnn           # Copy em dash (—) to clipboard
$ _mnn
Error: This script must be invoked as 'en_' or 'em_'

Each inline conditional in usage() tested only for en_, so every name other than en_, including a symlink under any other name, fell through to the em-dash text.

usage() now picks its text by name:

  • en_ and em_ each describe their own dash and point to the other command. The note about invoking the script as en_ or em_ is gone from their help, since it told the reader to do what they had already done.
  • Every other name gets a description of the shared implementation that lists both commands and their dashes, with no Examples: section, because no example would work.
$ en_ --help
Usage: en_ [OPTIONS]

Copies an en dash (–, U+2013) to the system clipboard. Use em_ for an em dash.

Options:
  -h, --help    Show this help message and exit.

Examples:
  en_
$ _mnn --help
Usage: _mnn [OPTIONS]

Shared implementation of en_ and em_; run it through one of those names.
The name decides which dash is copied to the system clipboard:

  en_   en dash (–, U+2013)
  em_   em dash (—, U+2014)

Options:
  -h, --help    Show this help message and exit.

Tests

Two _mnn help tests asserted the wording of the misdirected note; those assertions are removed. Six tests are added, and all six failed before the fix. The central one checks that every line of help that shows a dash (glyph or code point) also names the command that copies it, so the help can't say that the invoked name copies one. Against the old code, it flagged exactly the two false lines above.

Verification

  • make test: 332 of 332 pass (Linux and Windows clipboard tests skip on macOS).
  • tests/_mnn.bats under /bin/bash 3.2.57: 43 of 43 pass.
  • make run-pre-commit: clean.

🤖 Generated with Claude Code

Run as _mnn, or through any name other than en_ or em_, the help said
that the command copies an em dash and gave a bare invocation as an
example, but that invocation exits 1. Each inline conditional in usage()
tested only for en_, so every other name fell through to the em-dash
text.

usage() now picks its text by name. en_ and em_ each describe their own
dash and point to the other command. Every other name gets a description
of the shared implementation that lists both commands, with no example.
The note about invoking the script as en_ or em_ is gone from their own
help, where it told the reader to do what they had already done.

The tests now check that every line of help that shows a dash names the
command that copies it, in place of asserting the note's wording.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings September 23, 2026 19:04
@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Tip of the day
💡 Did you know, you can reply 'qodo' on any finding to push back, ask questions, or dig deeper

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Correct _mnn help by invocation name

🐞 Bug fix 🧪 Tests 🕐 10-20 Minutes

Grey Divider

AI Description

• Makes help truthful for direct, supported, and unrecognized invocation names.
• Direct help documents both supported commands without unusable examples.
• Adds regression coverage for command-to-dash attribution and sibling guidance.
Diagram

graph TD
  A["Help request"] --> B["usage()"] --> C{"Script name"} -->|en_| D["en_ help"]
  C -->|em_| E["em_ help"]
  C -->|other| F["Shared help"]
Loading
High-Level Assessment

The explicit case dispatch is appropriate because it mirrors the script's existing name-based behavior and keeps unsupported-name help distinct from executable examples. A generalized lookup table would add indirection without reducing meaningful complexity for only two supported aliases.

Files changed (2) +84 / -7

Bug fix (1) +29 / -5
_mnnGenerate accurate help for each invocation name +29/-5

Generate accurate help for each invocation name

• Refactors 'usage()' to select command-specific text for 'en_' and 'em_', including guidance to the sibling command. Direct and unrecognized names now describe the shared implementation, list both valid commands, and omit unusable examples.

_mnn

Tests (1) +55 / -2
_mnn.batsCover help attribution across supported and unsupported names +55/-2

Cover help attribution across supported and unsupported names

• Adds assertions for sibling-command guidance, removal of redundant invocation notes, and accurate command-to-dash attribution. Extends direct and symlinked-name coverage while removing assertions tied to the misleading text.

tests/_mnn.bats

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The functional changes align with the PR description and the added tests cover the corrected help-text behavior, with only a minor test-helper readability nit noted.

Review effort: Lite
Findings: 1 Low severity

Open (1)
What changed in this PR

This PR fixes _mnn --help output so it no longer falsely claims that invoking the shared implementation under an arbitrary name will copy a specific dash; help text is now selected based on SCRIPT_NAME and provides accurate, name-appropriate guidance.

Changes:

  • Refactors _mnn usage() to use a case on SCRIPT_NAME, emitting distinct help for en_, em_, and a “shared implementation” help for all other names.
  • Removes the misleading “must be invoked as…” note from en_/em_ help while keeping direct-invocation error behavior intact.
  • Updates and expands tests/_mnn.bats to validate correct help attribution and prevent future regressions.
File Description
_mnn Reworks usage() to generate accurate help text based on the invoked name (en_, em_, or other).
tests/​_mnn.bats Adds targeted help-text assertions and removes assertions that enforced the previously-misleading note.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tests/_mnn.bats
michen00 and others added 2 commits September 23, 2026 13:32
assert_dashes_attributed_to_commands appended the em-dash scan to the
en-dash scan with stray+=$(...). Command substitution strips trailing
newlines, so when both scans found stray lines, the last en-dash line
and the first em-dash line ran together in the failure message. Both
scans now run in one command substitution, which keeps one stray line
per line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The help-text selection logic is corrected cleanly and the added/updated tests directly cover the previously incorrect behavior without introducing observable regressions.

Review effort: Lite
Findings: None

Resolved since last review (1)

@michen00
michen00 merged commit 6196944 into main Sep 23, 2026
12 checks passed
@michen00
michen00 deleted the fix/mnn-help-text branch September 23, 2026 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants