cli: allow variant binaries to set AppName #11

Closed
opened 2026-02-22 19:17:17 +00:00 by Virgil · 1 comment
Member

Problem

pkg/cli/app.go hardcodes AppName = "core". When domain repos like LEM build standalone binaries using cli.Main(), the help text shows core instead of the binary's actual name:

Usage:
  core [command]    ← should be "lem [command]"

Proposal

Add a cli.WithAppName(name string) option that can be passed to cli.Main():

cli.Main(
    cli.WithAppName("lem"),
    cli.WithCommands("lem", lemcmd.AddLEMCommands),
)

Alternative: auto-detect from filepath.Base(os.Args[0]) as a fallback when no explicit name is set.

Context

Discovered while migrating LEM (first external consumer of pkg/cli) from manual switch os.Args[1] to the WithCommands pattern.

Acceptance

  • cli.Main() accepts an app name option
  • Help text shows the configured name
  • Shell completion uses the configured name
  • Existing core binary behaviour unchanged (defaults to "core")
  • Test coverage for the option
## Problem `pkg/cli/app.go` hardcodes `AppName = "core"`. When domain repos like LEM build standalone binaries using `cli.Main()`, the help text shows `core` instead of the binary's actual name: ``` Usage: core [command] ← should be "lem [command]" ``` ## Proposal Add a `cli.WithAppName(name string)` option that can be passed to `cli.Main()`: ```go cli.Main( cli.WithAppName("lem"), cli.WithCommands("lem", lemcmd.AddLEMCommands), ) ``` Alternative: auto-detect from `filepath.Base(os.Args[0])` as a fallback when no explicit name is set. ## Context Discovered while migrating LEM (first external consumer of `pkg/cli`) from manual `switch os.Args[1]` to the `WithCommands` pattern. ## Acceptance - [ ] `cli.Main()` accepts an app name option - [ ] Help text shows the configured name - [ ] Shell completion uses the configured name - [ ] Existing `core` binary behaviour unchanged (defaults to "core") - [ ] Test coverage for the option
Author
Member

Completed by Charon in core/cli (e360115). CLI package now lives at forge.lthn.ai/core/cli/pkg/cli, not core/go/pkg/cli.

Completed by Charon in `core/cli` (e360115). CLI package now lives at `forge.lthn.ai/core/cli/pkg/cli`, not `core/go/pkg/cli`.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: core/go#11
No description provided.