cmd

package
v0.1.18 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2026 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Execute

func Execute()

Execute runs the root command with proper exit code handling.

func SetVersionInfo added in v0.1.0

func SetVersionInfo(version, commit, date string)

SetVersionInfo sets version information for the CLI. This is called from main.go with values injected by GoReleaser.

Types

type CommandContext added in v0.1.0

type CommandContext struct {
	Ctx               context.Context
	Cancel            context.CancelFunc
	Config            *config.Config
	TeamID            string
	AuthRole          string
	AuthToken         string
	AuthCookie        string
	AuthUserID        string
	AuthBotID         string
	Client            *slack.APIClient
	CacheStore        *cache.Store
	ChannelResolver   *channels.Resolver
	UserResolver      *users.Resolver
	UserGroupResolver *usergroups.Resolver
}

CommandContext encapsulates common dependencies for command handlers. It eliminates boilerplate setup code that was previously duplicated across 20+ command handlers.

func NewCommandContext added in v0.1.0

func NewCommandContext(cmd *cobra.Command, timeout time.Duration) (*CommandContext, error)

NewCommandContext initializes all common dependencies needed by commands. Pass timeout=0 to use the default timeout of 30 seconds.

func NewCommandContextWithToken added in v0.1.3

func NewCommandContextWithToken(cmd *cobra.Command, timeout time.Duration, token string) (*CommandContext, error)

NewCommandContextWithToken creates a minimal context with a provided token. This is useful for verifying tokens before saving them to config. It does not initialize cache or resolvers since those require team ID.

func NewStreamingCommandContext added in v0.1.8

func NewStreamingCommandContext(cmd *cobra.Command) (*CommandContext, error)

NewStreamingCommandContext initializes command dependencies without applying a deadline to the command context, while still using a bounded setup call for auth/team discovery.

func NewStreamingCommandContextWithToken added in v0.1.8

func NewStreamingCommandContextWithToken(cmd *cobra.Command, token, cookie string) (*CommandContext, error)

NewStreamingCommandContextWithToken initializes streaming command dependencies using an explicit API token while preserving the loaded config for app-level settings.

func (*CommandContext) Close added in v0.1.0

func (c *CommandContext) Close()

Close releases resources held by the CommandContext. Always defer Close() after creating a CommandContext.

func (*CommandContext) EnsureAuthIdentity added in v0.1.9

func (c *CommandContext) EnsureAuthIdentity(ctx context.Context) error

EnsureAuthIdentity fills in the active Slack user/bot IDs when the context was created with SLACK_TEAM_ID and skipped auth.test during setup.

func (*CommandContext) ResolveChannel added in v0.1.0

func (c *CommandContext) ResolveChannel(input string) (string, error)

ResolveChannel converts a channel name or ID to a channel ID. Convenience method that wraps ChannelResolver.ResolveID.

type LoginResult added in v0.1.3

type LoginResult struct {
	OK         bool   `json:"ok"`
	ConfigPath string `json:"config_path"`
	TokenType  string `json:"token_type"`
	Verified   bool   `json:"verified,omitempty"`
	UserID     string `json:"user_id,omitempty"`
	TeamID     string `json:"team_id,omitempty"`
}

LoginResult represents the result of the login command

type OAuthTokenResponse added in v0.1.2

type OAuthTokenResponse struct {
	OK          bool   `json:"ok"`
	Error       string `json:"error,omitempty"`
	AccessToken string `json:"access_token,omitempty"`
	TokenType   string `json:"token_type,omitempty"`
	Scope       string `json:"scope,omitempty"`
	BotUserID   string `json:"bot_user_id,omitempty"`
	AppID       string `json:"app_id,omitempty"`
	Team        struct {
		ID   string `json:"id"`
		Name string `json:"name"`
	} `json:"team,omitempty"`
	AuthedUser struct {
		ID          string `json:"id"`
		Scope       string `json:"scope"`
		AccessToken string `json:"access_token"`
		TokenType   string `json:"token_type"`
	} `json:"authed_user,omitempty"`
}

OAuthTokenResponse represents Slack's oauth.v2.access response

Jump to

Keyboard shortcuts

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