Documentation
¶
Index ¶
- Variables
- func Execute()
- func FormatBool(b bool) string
- func FormatDuration(secs int) string
- func FormatPrivate(b bool) string
- func FormatTime(t time.Time) string
- func FormatTimePtr(t *time.Time) string
- func KV(label, value string)
- func KVf(label, format string, args ...any)
- func ParseArgs(cmd *cobra.Command, args []string, trailingArgsCount int) (workspace, repoSlug string, trailing []string, err error)
- func PrintJSON(data any)
- func PrintJSONError(err error)
- func PrintOrJSON(cmd *cobra.Command, data any, formatter func())
- func PrintPaginationFooter(size, page, pageLen int, hasNext bool)
- func Truncate(s string, maxLen int) string
- type Table
Constants ¶
This section is empty.
Variables ¶
var RootCmd = &cobra.Command{ Use: "bbkt", Version: version.Version, Short: "A unified CLI and MCP server for Bitbucket Cloud", Long: `bbkt is a complete command-line interface and Model Context Protocol server for Bitbucket Cloud. Manage workspaces, repositories, pull requests, pipelines, and source code from your terminal, or expose the same capabilities to AI agents via 'bbkt mcp'. Most commands auto-detect the current workspace/repo from your git config when run inside a clone, so 'bbkt prs list' Just Works. Credentials are stored at ~/.config/bbkt/credentials.json. Use --profile (or BBKT_PROFILE) to switch between named profiles (e.g. personal vs work).`, Example: ` # First-time setup bbkt auth # save credentials to default profile bbkt status # confirm you're authenticated # Daily use (inside a Bitbucket repo) bbkt prs list # workspace/repo inferred from git # Outside a clone: pin scope with flag, env, or positional bbkt -R myws/myrepo prs list # --repo workspace/slug (gh-style) bbkt -W myws repos list # workspace-only BBKT_REPO=myws/myrepo bbkt prs list # Multi-account bbkt auth --profile work bbkt --profile work prs list # one-shot profile override # MCP server (for Claude Desktop / Cursor / etc.) bbkt mcp`, PersistentPreRun: func(cmd *cobra.Command, args []string) { if profile, _ := cmd.Flags().GetString("profile"); profile != "" { os.Setenv("BBKT_PROFILE", profile) } }, SilenceErrors: true, SilenceUsage: true, }
RootCmd represents the base command when called without any subcommands
Functions ¶
func Execute ¶
func Execute()
Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.
func FormatBool ¶ added in v0.1.3
FormatBool returns a readable yes/no.
func FormatDuration ¶ added in v0.1.3
FormatDuration formats seconds into a human-readable duration.
func FormatPrivate ¶ added in v0.1.3
FormatPrivate returns "private" or "public".
func FormatTime ¶ added in v0.1.3
FormatTime formats a time.Time as a short human-readable string.
func FormatTimePtr ¶ added in v0.1.3
FormatTimePtr handles nil time pointers.
func KV ¶ added in v0.1.3
func KV(label, value string)
KV prints a labeled key-value pair with consistent padding.
func ParseArgs ¶
func ParseArgs(cmd *cobra.Command, args []string, trailingArgsCount int) (workspace, repoSlug string, trailing []string, err error)
ParseArgs resolves workspace and repoSlug for a subcommand and returns any remaining positional args after the (optional) workspace/repo prefix.
trailingArgsCount is the number of non-workspace/repo positional args the subcommand expects (e.g. 1 for `get <pr-id>`, 0 for `list`). Callers may pass -1 to opt out of trailing-arg accounting — used by `repos list` where the only positional is the workspace itself.
func PrintJSON ¶
func PrintJSON(data any)
PrintJSON formats any Go struct as pretty JSON and prints to stdout.
func PrintJSONError ¶ added in v0.1.9
func PrintJSONError(err error)
PrintJSONError writes an error as a JSON object to stderr, so that a caller running with --json gets structured error output on the error path too, instead of a human-readable "Error: ..." line.
func PrintOrJSON ¶ added in v0.1.3
PrintOrJSON prints formatted output or JSON depending on the --json flag. The formatter func should print the human-readable output.
func PrintPaginationFooter ¶ added in v0.1.3
PrintPaginationFooter prints a summary line showing current page info. When hasNext is true, includes a hint to fetch the next page with --page.
Types ¶
type Table ¶ added in v0.1.3
type Table struct {
// contains filtered or unexported fields
}
Table is a simple tabwriter-based table printer.
func NewTable ¶ added in v0.1.3
func NewTable() *Table
NewTable creates a new table with tabwriter defaults.
func (*Table) Flush ¶ added in v0.1.3
func (t *Table) Flush()
Flush flushes the underlying tabwriter.