diff --git a/CHANGELOG.md b/CHANGELOG.md index 1032b4ce..fecc5d01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +- List the commands in `clickclack help`, `-h`, and `--help` instead of only the client flags; `clickclack help` no longer fails with `unknown command "help"`. Thanks @KrasimirKralev. + ## 0.9.4 - 2026-11-05 **Highlights:** Clearer client configuration and signed-out session errors, with refreshed desktop and database dependencies. diff --git a/apps/api/cmd/clickclack/client.go b/apps/api/cmd/clickclack/client.go index aa7f96cc..ecb0157c 100644 --- a/apps/api/cmd/clickclack/client.go +++ b/apps/api/cmd/clickclack/client.go @@ -55,6 +55,7 @@ func client(args []string) error { opts := defaults.opts flags := flag.NewFlagSet("clickclack", flag.ExitOnError) addClientFlags(flags, &opts) + flags.Usage = func() { printUsage(flags) } if err := flags.Parse(args); err != nil { return err } @@ -64,6 +65,9 @@ func client(args []string) error { } c := apiClient{opts: opts, defaults: defaults, http: &http.Client{Timeout: 10 * time.Second}} switch rest[0] { + case "help": + printUsage(flags) + return nil case "login": return c.login(rest[1:]) case "logout": @@ -147,6 +151,40 @@ func sameServer(left, right string) bool { return strings.TrimRight(left, "/") == strings.TrimRight(right, "/") } +// Keep in sync with the command block in docs/cli.md. +const usageCommands = `Usage: clickclack [flags] + +Commands: + serve run the HTTP/WebSocket server (default if no command given) + migrate apply embedded SQL migrations + admin bootstrap, FakeCo seed, user create, member add, invite create, bot create, events prune, magic-link create, webpush keygen + backup write a SQLite backup file + export write a JSON dump to a file or stdout + version print the binary version + help show this help + login consume a magic-link token and store/print a session token + logout revoke the stored session and remove stored client credentials + whoami print the current server-side user + status print selected server/user/workspace/channel + canary prove a human ClickClack -> OpenClaw -> quoted bot reply round trip + workspaces list + channels list + send + messages send + messages list + threads open + threads reply + reactions add + reactions remove + +Client flags (before the command or on the command itself): +` + +func printUsage(flags *flag.FlagSet) { + fmt.Fprint(flags.Output(), usageCommands) + flags.PrintDefaults() +} + func addClientFlags(flags *flag.FlagSet, opts *clientOptions) { flags.StringVar(&opts.Server, "server", opts.Server, "ClickClack server URL") flags.StringVar(&opts.Token, "token", opts.Token, "session bearer token") diff --git a/apps/api/cmd/clickclack/client_config_test.go b/apps/api/cmd/clickclack/client_config_test.go index 6ebae158..79400a28 100644 --- a/apps/api/cmd/clickclack/client_config_test.go +++ b/apps/api/cmd/clickclack/client_config_test.go @@ -73,3 +73,19 @@ func TestDefaultClientOptionsIsQuietWithValidConfig(t *testing.T) { t.Fatalf("defaults = %+v, want the stored server", defaults) } } + +func TestHelpListsCommandsAndClientFlags(t *testing.T) { + t.Setenv("XDG_CONFIG_HOME", t.TempDir()) + var err error + output := captureStderr(t, func() { + err = runArgs([]string{"clickclack", "help"}) + }) + if err != nil { + t.Fatalf("help returned %v", err) + } + for _, want := range []string{"Commands:", " serve ", " admin ", " login ", " messages list", "-server", "-workspace"} { + if !strings.Contains(output, want) { + t.Fatalf("help output missing %q:\n%s", want, output) + } + } +} diff --git a/docs/cli.md b/docs/cli.md index 23dac501..28f99fec 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -20,6 +20,8 @@ Commands: admin bootstrap, FakeCo seed, user create, member add, invite create, bot create, events prune, magic-link create, webpush keygen backup write a SQLite backup file export write a JSON dump to a file or stdout + version print the binary version + help show this help login consume a magic-link token and store/print a session token logout revoke the stored session and remove stored client credentials whoami print the current server-side user @@ -36,6 +38,9 @@ Commands: reactions remove ``` +`clickclack help`, `clickclack -h`, and `clickclack --help` print this command +list followed by the client flags. + Client commands accept these common flags before the command or on the command itself: