cmdutil

package
v0.9.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 6, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddJSONFlags

func AddJSONFlags(cmd *cobra.Command, flags *JSONFlags)

AddJSONFlags adds --json, --jq, and --template flags to a command.

func IsAuthError

func IsAuthError(err error) bool

IsAuthError checks if the error is an AuthError.

func IsSilentError

func IsSilentError(err error) bool

IsSilentError checks if the error is a SilentError.

func IsTokenTypeError

func IsTokenTypeError(err error) bool

IsTokenTypeError checks if the error is a TokenTypeError.

func NeedsAuth

func NeedsAuth(f *Factory) func(cmd *cobra.Command, args []string) error

NeedsAuth returns a pre-run function that validates any token is available.

func NeedsBotToken

func NeedsBotToken(f *Factory) func(cmd *cobra.Command, args []string) error

NeedsBotToken returns a pre-run function that validates a bot token is available.

func NeedsUserToken

func NeedsUserToken(f *Factory) func(cmd *cobra.Command, args []string) error

NeedsUserToken returns a pre-run function that validates a user token is available.

Types

type AuthError

type AuthError struct {
	Message string
}

AuthError indicates an authentication failure.

func (*AuthError) Error

func (e *AuthError) Error() string

type Factory

type Factory struct {
	IOStreams *iostreams.IOStreams
	// contains filtered or unexported fields
}

Factory provides lazy-initialized dependencies to commands.

func NewFactory

func NewFactory(ios *iostreams.IOStreams) *Factory

NewFactory creates a new Factory with the given IOStreams.

func (*Factory) BotClient

func (f *Factory) BotClient() (*api.Client, error)

BotClient returns a Slack API client authenticated with the bot token (cached).

func (*Factory) Config

func (f *Factory) Config() (*config.Config, error)

Config returns the loaded configuration (cached after first call).

func (*Factory) DefaultClient

func (f *Factory) DefaultClient() (*api.Client, error)

DefaultClient returns the bot client if available, otherwise the user client.

func (*Factory) IsAgentMode added in v0.8.0

func (f *Factory) IsAgentMode() bool

IsAgentMode returns true when SLACKBUZZ_AGENT=1 is set. Agent mode prefers bot tokens, disables interactive prompts, and outputs structured JSON errors to stderr.

func (*Factory) UserClient

func (f *Factory) UserClient() (*api.Client, error)

UserClient returns a Slack API client authenticated with the user token (cached).

type JSONFlags

type JSONFlags struct {
	JSON     bool
	JQ       string
	Template string
}

JSONFlags holds the --json, --jq, and --template flags.

func (*JSONFlags) OutputJSON

func (f *JSONFlags) OutputJSON(w io.Writer, data interface{}) error

OutputJSON writes data as JSON, optionally filtered by jq or formatted by a template.

func (*JSONFlags) WantsJSON

func (f *JSONFlags) WantsJSON() bool

WantsJSON returns true if JSON output is requested (via --json, --jq, or --template).

type SilentError

type SilentError struct {
	Err error
}

SilentError is an error that should not be printed (the command already handled output).

func (*SilentError) Error

func (e *SilentError) Error() string

func (*SilentError) Unwrap

func (e *SilentError) Unwrap() error

type TokenTypeError

type TokenTypeError struct {
	Need    string // "bot" or "user"
	Message string
}

TokenTypeError indicates the wrong token type was used.

func (*TokenTypeError) Error

func (e *TokenTypeError) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL