Skip to content

Replace per-command custom help with a global styled renderer#229

Merged
jeremy merged 2 commits intomainfrom
clean-help
Mar 10, 2026
Merged

Replace per-command custom help with a global styled renderer#229
jeremy merged 2 commits intomainfrom
clean-help

Conversation

@jeremy
Copy link
Member

@jeremy jeremy commented Mar 10, 2026

Summary

  • Adds renderCommandHelp in help.go — a single function that renders styled help for every non-root command, reading structure from cobra's command tree
  • Deletes RegisterCustomHelp/CustomHelp registry, renderProjectsHelp, and the defaultHelp fallback parameter from rootHelpFunc
  • Inherited flags are curated uniformly: parent-defined persistent flags always appear (provenance checked by pointer identity), root globals are filtered to a salient set (--account, --json, --md, --project, --quiet)
  • Moves projects examples into cobra's Example field so the generic renderer picks them up

Motivation

The projects command had a hand-crafted help renderer to avoid cobra's default dumping 20+ inherited flags inline. But the customHelp map approach doesn't scale — every new command group would need its own bespoke renderer. This replaces it with one renderer that applies everywhere, matching the styled-section layout (USAGE, COMMANDS, FLAGS, INHERITED FLAGS, EXAMPLES, LEARN MORE) already used for root help.

filterInheritedFlags determines flag provenance by pointer identity: if a flag is the same object as the one on root's PersistentFlags, it's a root global subject to the salient allowlist. A parent that redefines the same name (e.g. --project on messages) produces a different pointer and always passes through.

Test plan

  • make check passes (fmt, vet, lint, unit tests, e2e, surface snapshot, provenance)
  • Visual spot-check: basecamp projects --help, basecamp projects list --help, basecamp campfire post --help, basecamp timesheet report --help
  • Agent help still works: basecamp projects --agent --help | jq .

@jeremy jeremy requested a review from a team as a code owner March 10, 2026 10:07
Copilot AI review requested due to automatic review settings March 10, 2026 10:07
@github-actions github-actions bot added commands CLI command implementations tests Tests (unit and e2e) enhancement New feature or request labels Mar 10, 2026
@jeremy jeremy requested a review from dhh March 10, 2026 10:09
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 6 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="internal/cli/help.go">

<violation number="1" location="internal/cli/help.go:287">
P2: The LEARN MORE section is empty for leaf commands directly under root (e.g., `basecamp search --help`, `basecamp todo --help`). The second condition excludes commands whose parent is root, so neither branch writes any content after the header. Removing the `cmd.Parent() != cmd.Root()` guard would show `basecamp --help` for these commands, which is the sensible fallback.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR replaces per-command custom help renderers with a single global styled help renderer for all non-root commands, relying on Cobra’s command tree and metadata (Use/Short/Long/Example/flags) to generate consistent help output.

Changes:

  • Adds renderCommandHelp and updates rootHelpFunc to render styled help for all subcommands (and keep agent-mode JSON).
  • Removes the custom-help registry (RegisterCustomHelp / CustomHelp) and deletes the bespoke projects help renderer.
  • Moves projects examples into Cobra’s Example field and updates tests/e2e assertions to match the new styled output.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
internal/cli/help.go Implements global styled help dispatch and adds renderCommandHelp for all non-root commands.
internal/cli/root.go Switches root command to use the new rootHelpFunc() signature.
internal/cli/help_test.go Updates/extends tests to assert styled help for subcommands and flag rendering behavior.
internal/commands/commands.go Removes the custom help function registry types and map.
internal/commands/projects.go Removes bespoke projects help; adds Example so the generic renderer can display examples.
e2e/cards_columns_steps.bats Updates expectations from Cobra’s default “Available Commands” to styled “COMMANDS”.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 79529a1b63

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copilot AI review requested due to automatic review settings March 10, 2026 10:23
@jeremy
Copy link
Member Author

jeremy commented Mar 10, 2026

Addressed all review feedback in 0acaad5:

  • LEARN MORE empty for root-level leaves (cubic, copilot): removed cmd.Parent() != cmd.Root() guard — all leaf commands now show <parent> --help
  • USAGE for non-runnable groups (copilot): groups without RunE now render <command> [flags] instead of bare [flags]
  • Missing test for root-level leaf (copilot): added TestRootLevelLeafCommandHelp
  • Example indentation (copilot): renders correctly, no change needed
  • Hardcoded inherited flags (codex): already fixed in f39e39c

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 2 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="internal/cli/help.go">

<violation number="1" location="internal/cli/help.go:304">
P2: `filterInheritedFlags` filters root-level flags for all commands, but per the design intent (and the inline comment referencing 'leaf help'), group commands should show the full inherited set. Add an early return for group commands so they get unfiltered inherited flags.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Copilot AI review requested due to automatic review settings March 10, 2026 10:34
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

jeremy added 2 commits March 10, 2026 03:51
One renderCommandHelp in help.go now handles all non-root commands,
reading structure from cobra's command tree instead of hardcoding
per-command. Deletes the RegisterCustomHelp registry and the bespoke
renderProjectsHelp.

Inherited flags are curated: parent-defined persistent flags always
appear (--project, --campfire, --content-type, etc.), root globals
are filtered to a salient set (--account, --json, --md, --project,
--quiet).
Group commands without RunE now show "<command> [flags]" in USAGE
instead of bare "[flags]". Root-level leaf commands (todo, done, etc.)
now show "basecamp --help" in LEARN MORE instead of an empty section.
Copilot AI review requested due to automatic review settings March 10, 2026 10:53
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jeremy jeremy requested a review from robzolkos March 10, 2026 11:00
@jeremy jeremy merged commit 9008d3e into main Mar 10, 2026
28 checks passed
@jeremy jeremy deleted the clean-help branch March 10, 2026 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands CLI command implementations enhancement New feature or request tests Tests (unit and e2e)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants