Documentation
¶
Overview ¶
Package cli builds the urfave/cli/v3 command tree for the bagit binary.
Commands are constructed via factory functions that take a Deps struct so tests can swap I/O streams, the working directory, and the clock without touching globals.
Index ¶
- func NewAICommand(deps Deps) *cli.Command
- func NewAssetsCommand(deps Deps) *cli.Command
- func NewAttachCommand(deps Deps) *cli.Command
- func NewBodyCommand(deps Deps) *cli.Command
- func NewCommentCommand(deps Deps) *cli.Command
- func NewCommentsCommand(deps Deps) *cli.Command
- func NewConfigCommand(deps Deps) *cli.Command
- func NewEditCommand(deps Deps) *cli.Command
- func NewInitCommand(deps Deps) *cli.Command
- func NewListCommand(deps Deps) *cli.Command
- func NewMvCommand(deps Deps) *cli.Command
- func NewNewCommand(deps Deps) *cli.Command
- func NewOpenCommand(deps Deps) *cli.Command
- func NewPathCommand(deps Deps) *cli.Command
- func NewRmCommand(deps Deps) *cli.Command
- func NewRootCommand(deps Deps) *cli.Command
- func NewSearchCommand(deps Deps) *cli.Command
- func NewShowCommand(deps Deps) *cli.Command
- func NewSkillsCommand(deps Deps) *cli.Command
- func NewStatsCommand(deps Deps) *cli.Command
- func NewStatusShortcutCommand(deps Deps, name string, target store.Status, usage string) *cli.Command
- func NewTUICommand(deps Deps) *cli.Command
- func NewTagCommand(deps Deps) *cli.Command
- func NewTemplatesCommand(deps Deps) *cli.Command
- func NewValidateCommand(deps Deps) *cli.Command
- func NewXrefCommand(deps Deps) *cli.Command
- func Run(ctx context.Context, deps Deps, args []string) int
- type Deps
- type Stats
- type ValidationIssue
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewAICommand ¶
NewAICommand builds `bagit ai` with `list` and `<action> <id>` forms.
Action definitions live in `[ai.actions.<name>]` config blocks. The args support {item_path}, {item_dir}, {item_id}, {title} substitution before being passed to the configured command. Stdout/stderr/stdin are wired straight through so users see the tool's output live.
func NewAssetsCommand ¶
NewAssetsCommand builds `bagit assets <id>`.
func NewAttachCommand ¶
NewAttachCommand builds `bagit attach <id> <path>` and the `attach rm` subcommand for removing an attachment by name.
func NewBodyCommand ¶
NewBodyCommand builds `bagit body <id>`. It lets agents and scripts read or replace the markdown body of an item without spawning $EDITOR.
Resolution order for the new body content:
- -m/--message string flag.
- -f/--file path flag (use "-" for stdin).
- Trailing positional args joined with spaces.
- Buffered stdin in tests. In production, use -f - for stdin.
If no input is provided, the existing body is written to stdout. The `--append` flag preserves the existing body and appends a blank line plus the new content.
func NewCommentCommand ¶
NewCommentCommand builds `bagit comment <id> [body]`. If body is omitted and stdin is not a TTY, the comment body is read from stdin. Otherwise, --message must be supplied. The author defaults to the GIT_AUTHOR or USERNAME env vars.
func NewCommentsCommand ¶
NewCommentsCommand builds `bagit comments <id>`.
func NewConfigCommand ¶
NewConfigCommand builds `bagit config` with `get` / `set` / `show`.
func NewEditCommand ¶
NewEditCommand builds `bagit edit <id>`. It opens the item.md in the resolved editor and refreshes the Updated stamp on success.
func NewInitCommand ¶
NewInitCommand builds the `bagit init` subcommand. Init scaffolds the `.bagit/` directory (config, tags registry, items dir), refreshes the repo-root AGENTS.md block, updates `.gitignore`, and optionally writes tool-specific skill files. On a TTY it asks questions to seed config; non-TTY runs and `--yes` use the supplied defaults / overrides.
func NewListCommand ¶
NewListCommand builds `bagit list`.
`list` is the no-query degenerate case of `search`: it shares the same structured filters and output renderers, and delegates filtering to search.ApplyFilter so there is a single source of truth for the OR-within-field / AND-across-fields semantics.
func NewMvCommand ¶
NewMvCommand builds `bagit mv <id> <status>`.
func NewNewCommand ¶
NewNewCommand builds `bagit new <title>`. With no title argument on a TTY (and without --yes) it launches a small huh form to scaffold the item; otherwise it stays non-interactive and behaves as before.
func NewOpenCommand ¶
NewOpenCommand builds `bagit open <id>`. It opens the item directory using the platform's default file/URL handler so the user can browse assets, attach files, etc.
func NewPathCommand ¶
NewPathCommand builds `bagit path <id>`. It prints the absolute path to the item.md file, suitable for use in shell pipelines (e.g. `code $(bagit path 42)`).
func NewRmCommand ¶
NewRmCommand builds `bagit rm <id>`. Deletion is a hard remove of the item directory; the user must confirm interactively unless --yes is set.
func NewRootCommand ¶
NewRootCommand constructs the top-level `bagit` command with all subcommands attached.
func NewSearchCommand ¶
NewSearchCommand builds `bagit search [query]`.
func NewShowCommand ¶
NewShowCommand builds `bagit show <id>`.
func NewSkillsCommand ¶
NewSkillsCommand builds `bagit skills` with install/regenerate subcommands. Both write tool-specific skill files for OpenCode, Claude, Cursor, and Copilot. `install` defaults to auto-detecting tools when --for and positional tool names are omitted.
func NewStatsCommand ¶
NewStatsCommand builds `bagit stats`.
func NewStatusShortcutCommand ¶
func NewStatusShortcutCommand(deps Deps, name string, target store.Status, usage string) *cli.Command
NewStatusShortcutCommand builds the `start`, `done`, and `reopen` shortcuts that move an item directly to a fixed status.
func NewTUICommand ¶
NewTUICommand builds `bagit i` (aliases: `interactive`, `tui`). It launches the bubbletea-driven TUI rooted at the resolved bagit repo.
func NewTagCommand ¶
NewTagCommand builds `bagit tag` and its subcommands. Top-level invocation (`bagit tag`) lists known tags from the registry; item tag mutations grow the registry, and explicit `add` lets users seed metadata up front.
func NewTemplatesCommand ¶
NewTemplatesCommand builds `bagit templates` with `eject` and `reset` subcommands. Templates are the embedded markdown bodies used when creating new items via `bagit new`; ejecting writes them to .bagit/templates/<t>.md for user editing, and resetting deletes the override so the embedded version takes over again.
func NewValidateCommand ¶
NewValidateCommand builds `bagit validate`. It walks .bagit/items and reports unparseable directories, malformed item.md files, duplicate ids, slug drift, broken xrefs, missing asset references, and unknown tags.
func NewXrefCommand ¶
NewXrefCommand builds `bagit xref [id]`. With no id, it lists every cross-reference in the backlog. With an id, it lists the inbound and outbound xrefs for that item.
Types ¶
type Deps ¶
type Deps struct {
WorkingDir string
Stdout io.Writer
Stderr io.Writer
Stdin io.Reader
// IsTTY reports whether stdout is connected to a terminal. When nil,
// commands assume false (safe default for piping).
IsTTY func() bool
}
Deps carries per-invocation dependencies for command actions. A zero-value Deps with the working directory set is sufficient for production use; tests override Stdout, Stderr, Stdin, and the working directory as needed.