Skip to content

Show ucm, not unison, as the program name in help and messages - #6343

Open
shu-chen-dot-ca wants to merge 2 commits into
unisonweb:trunkfrom
shu-chen-dot-ca:fix-6316-help-prog-name
Open

shu-chen-dot-ca wants to merge 2 commits into
unisonweb:trunkfrom
shu-chen-dot-ca:fix-6316-help-prog-name

Conversation

@shu-chen-dot-ca

Copy link
Copy Markdown

Overview

ucm --help told new users "To get started just run unison", and its usage lines said Usage: unison ..., but unison isn't a command people have. The release bundle starts the unison/unison executable from its ucm launcher script, and the nixpkgs package does the same with makeWrapper, so getProgName always gives unison.

Now these say ucm: the help, the usage lines (also on parse errors and subcommand help), --version, the transcript hints ("Run ucm --codebase ... to do more work with it") and the codebase-not-found message ("Run ucm --codebase-create <dir> to create one").

Fixes #6316

Implementation approach and notes

  • Unison.Main gets the name from a new getUserFacingProgName, which turns unison into ucm and leaves any other name as it is. All three places that called getProgName use it: main, runTranscripts and getCodebaseOrExit.
  • ArgParse.parseCLIArgs runs customExecParser under withProgName progName, because optparse-applicative looks up the program name itself for the Usage: lines it prints (on --help and on a parse error). renderUsage already took the name as an argument.

Interesting/controversial decisions

I mapped only the name unison instead of always showing ucm, so someone who copies or links the executable under a different name still sees that name. A side effect is that a development build run with stack exec unison -- --help also says ucm, since its executable has the same name. --version now prints ucm version: .... Nothing in the repo's scripts reads that prefix: check-version.bash and migration-test.sh only grep for the version or print the line.

Test coverage

  • Have you included tests (which could be a transcript) for this change, or is it somehow covered by existing tests?
  • Would you recommend improving the test coverage (either as part of this PR or as a separate issue) or do you think it’s adequate?
  • If you only tested by hand, because that's all that's practical to do for this change, mention that. Include screenshots.

Tested by hand, through a ucm launcher script like the release bundle's: ucm --help, ucm run --help, ucm transcript (missing argument), ucm --bogus, ucm --version and ucm -c <dir with no codebase> all say ucm. A copy of the executable named othername still says othername. Transcripts run through the transcripts test executable, not this main, so their output doesn't change. ./scripts/check.sh passes (tests, transcripts, formatting; migration cached), and the attestations are included.

Before After
before after

Loose ends

None.

Final checklist

  • Choose your PR title well: Your pull request title is what's used to create release notes, so please make it descriptive of the change itself, which may be different from the initial motivation to make the change.
  • Update your PR description if the specifics of the PR have changed over time.
  • Include transcripts or screenshots that demonstrate the changed behavior.
  • If you changed .cabal files, make sure the package.yaml files are up-to-date instead.

This branch has not been deployed

No deployments
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.

ucm help should not suggest running unison

1 participant