Skip to content

feat(cli): wrap cobra with charmbracelet/fang - #9

Merged
ironystock merged 1 commit into
feat/cli-leveled-loggerfrom
feat/cli-fang-wrap
Apr 28, 2026
Merged

ironystock merged 1 commit into
feat/cli-leveled-loggerfrom
feat/cli-fang-wrap

Conversation

@ironystock

@ironystock ironystock commented Apr 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Swaps `rootCmd.Execute()` for `fang.Execute(ctx, rootCmd, fang.WithVersion(version))` in `main()`.
  • All `--help` and subcommand `--help` output now renders with structured sections (USAGE / COMMANDS / FLAGS), aligned columns, and subdued styling.
  • Errors get a styled prefix on stderr.
  • `man` and `completion` subcommands ship for free (fang adds them).

Stacking

This PR is stacked on #8 (logger), which is stacked on #7 (refactor split). Base = `feat/cli-leveled-logger`. GitHub will auto-retarget as #7 → #8 → #9 merge in order.

Before / after (root --help)

Before (cobra default):
```
A portable, multi-directional memory system for AI.
...
Available Commands:
add Create a new memory
...
Flags:
-h, --help help for rememberize
```

After (fang):
```
A portable, multi-directional memory system for AI.

USAGE
rememberize [command] [--flags]

COMMANDS
add [--flags] Create a new memory
...

FLAGS
-h --help Help for rememberize
--json Output raw JSON (for scripting/piping)
-v --verbose Increase log verbosity (-v info, -vv debug)
```

Why `fang.WithVersion(version)`

Fang doesn't read cobra's `Version` field by default — without the option, `--version` reports `unknown (built from source)`. Passing the package-level `version` var (which goreleaser sets via `-ldflags`) wires it up.

Transitive dep skew

PR #8 brought in `charmbracelet/log v1.0.0`, which transitively pulled an older `x/cellbuf v0.0.13-...`. Fang needs `x/ansi v0.11.x`, but the older `cellbuf` was built against `x/ansi v0.8.x` and won't compile against the newer ansi.

Resolution: `go get github.com/charmbracelet/x/cellbuf@latest` brings both onto a coherent set (`cellbuf v0.0.15`, `ansi v0.11.5`). No source change required.

Verification

  • `go build ./...` clean.
  • `go test ./...` green (no test changes).
  • `./bin/rememberize --version` → `rememberize version dev`.
  • `./bin/rememberize --help` → styled output (see above).
  • `./bin/rememberize list --help` → styled subcommand help.
  • `./bin/rememberize completion bash` → fang's auto-generated bash completion script.

Test plan

  • CI green.
  • Manual sanity in a real terminal: confirm colored output renders. (Won't show in piped CI logs.)

Out of scope

No changes to any RunE. No flag renames. No behavior change.

🤖 Generated with Claude Code


View in Codesmith
Need help on this PR? Tag @codesmith with what you need.

  • Let Codesmith autofix CI failures and bot reviews

Drops fang.Execute(ctx, rootCmd, fang.WithVersion(version)) in for
plain rootCmd.Execute(). Net effect:

- --help and subcommand --help render with structured sections
  (USAGE / COMMANDS / FLAGS), aligned columns, subdued styling.
- Errors get a styled prefix on stderr.
- man and completion subcommands ship for free.
- --version still reports the build-time-injected `version` var via
  fang.WithVersion (fang otherwise reports "unknown" since it doesn't
  read cobra's Version field by default).

Transitive dep bump: charmbracelet/log (PR #8) brought in an older
x/cellbuf that's incompatible with x/ansi v0.11.x — fang requires the
newer ansi. go get github.com/charmbracelet/x/cellbuf@latest pulls
both onto a coherent set (cellbuf v0.0.15, ansi v0.11.5). No source
change needed.

Tests still green; no behavior change to any RunE.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@ironystock
ironystock merged commit d22bb78 into feat/cli-leveled-logger Apr 28, 2026
ironystock added a commit that referenced this pull request Apr 28, 2026
feat(cli): leveled logger + fang wrap (re-merge of #8 + #9)
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.

1 participant