From b216363e6363973eefab752eebf639381fd968b6 Mon Sep 17 00:00:00 2001 From: liangshuo-1 Date: Tue, 2 Jun 2026 20:31:45 +0800 Subject: [PATCH] fix(cli): remove FLAGS section from root --help (#1226) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Follow-up to #1223. The hand-written FLAGS block in `lark-cli --help` restated leaf-command flags at the root level — flags that are not registered on the root command (they error "unknown flag" there). Even trimmed to an illustrative example list, it duplicated information Cobra's per-command `--help` already renders authoritatively, and any static list in root help drifts from the real per-command flag sets over time. Drop the section entirely: Cobra's per-command `Flags:` output is the single source of truth. `USAGE:`/`EXAMPLES:` still show flags in context, and the `Flags:` block at the bottom of root help lists the actual root flags. Also removes the now-obsolete TestRootLong_FlagsSectionPointsToCommandHelp. --- cmd/root.go | 4 ---- cmd/root_test.go | 11 ----------- 2 files changed, 15 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index 31a97728f..41c6f5f59 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -48,10 +48,6 @@ EXAMPLES: # Generic API call lark-cli api GET /open-apis/calendar/v4/calendars -FLAGS: - e.g. --as, --format, -q/--jq, --dry-run ... - Run lark-cli --help for the full list. - AI AGENT SKILLS: lark-cli pairs with AI agent skills (Claude Code, etc.) that teach the agent Lark API patterns, best practices, and workflows. diff --git a/cmd/root_test.go b/cmd/root_test.go index ff1e3837b..3ab78ceb2 100644 --- a/cmd/root_test.go +++ b/cmd/root_test.go @@ -83,17 +83,6 @@ func TestRootLong_AgentSkillsLinkTargetsReadmeSection(t *testing.T) { } } -func TestRootLong_FlagsSectionPointsToCommandHelp(t *testing.T) { - // The flags shown in root help live on leaf commands (api, service), not - // on the root command — every one errors "unknown flag" at the top level. - // So the FLAGS section may only list them as examples and must route to - // ` --help` for the full set, rather than re-list them as if they - // were global root flags (which both lies and drifts as flags change). - if !strings.Contains(rootLong, "lark-cli --help") { - t.Fatalf("root help FLAGS section must point to `lark-cli --help` for the flag list, got:\n%s", rootLong) - } -} - func TestConfigureFlagCompletions(t *testing.T) { t.Cleanup(func() { cmdutil.SetFlagCompletionsEnabled(false) })