cmdutil

package
v0.32.0 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2026 License: MIT Imports: 22 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, --raw, and --template flags to a command.

func CreateSpaceTag added in v0.16.0

func CreateSpaceTag(client *api.Client, spaceID, tagName string) error

CreateSpaceTag creates a new tag in a ClickUp space. POST /api/v2/space/{space_id}/tag with body {"tag":{"name":"tag-name"}}

func CustomIDQueryParam added in v0.18.0

func CustomIDQueryParam(cfg *config.Config, isCustomID bool) string

CustomIDQueryParam returns the URL query string fragment for custom task ID resolution. Used by commands that build raw HTTP requests (e.g. comments).

Returns "" when isCustomID is false, or "?custom_task_ids=true&team_id=..." when true.

func CustomIDTaskQuery added in v0.29.0

func CustomIDTaskQuery(cfg *config.Config, isCustomID bool) string

CustomIDTaskQuery returns a query string for task endpoints supporting custom task IDs. Returns "" when isCustomID is false.

func CustomIDTaskQueryMD added in v0.29.0

func CustomIDTaskQueryMD(cfg *config.Config, isCustomID bool) string

CustomIDTaskQueryMD returns a query string for task endpoints supporting custom task IDs with markdown description and subtask inclusion.

func CustomIDTaskQueryWithSubtasks added in v0.29.0

func CustomIDTaskQueryWithSubtasks(cfg *config.Config, isCustomID bool) string

CustomIDTaskQueryWithSubtasks returns a query string for task endpoints supporting custom task IDs with subtask inclusion enabled.

func EnsureTagsExist added in v0.16.0

func EnsureTagsExist(client *api.Client, spaceID string, tags []string, w io.Writer) []string

EnsureTagsExist checks which tags already exist in the space and auto-creates any missing ones. Returns the full list of tag names (all guaranteed to exist). If the space tags cannot be fetched, tags are returned as-is (graceful fallback).

func FetchListStatuses added in v0.17.0

func FetchListStatuses(client *api.Client, listID string) ([]string, error)

FetchListStatuses fetches the available status names for a ClickUp list. Returns nil if the list doesn't have custom status overrides.

func FetchSpaceStatuses added in v0.9.0

func FetchSpaceStatuses(client *api.Client, spaceID string) ([]string, error)

FetchSpaceStatuses fetches the available status names for a ClickUp space.

func FetchSpaceTags added in v0.10.0

func FetchSpaceTags(client *api.Client, spaceID string) ([]string, error)

FetchSpaceTags fetches the available tag names for a ClickUp space.

func FormatRecentTaskOption added in v0.5.0

func FormatRecentTaskOption(t RecentTask) string

FormatRecentTaskOption formats a RecentTask for display in a selection prompt.

func GetCurrentUserID added in v0.11.0

func GetCurrentUserID(client *api.Client) (int, error)

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 LocationSummary added in v0.5.0

func LocationSummary(tasks []RecentTask) []string

LocationSummary returns a deduplicated summary of locations from recent tasks, e.g. "Folder > List" pairs. Useful for suggesting where to search.

func MatchSprintListID added in v0.15.0

func MatchSprintListID(lists []clickup.List, now time.Time) string

MatchSprintListID finds the list whose start/due date range contains the given time. Returns "" if no list matches.

func MatchStatus added in v0.9.0

func MatchStatus(target string, available []string) (string, error)

MatchStatus finds the best matching status from available statuses using a tiered strategy: 1. Exact match (case-insensitive) 2. Contains match (case-insensitive) 3. Fuzzy match using normalized fold ranking

func NeedsAuth

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

NeedsAuth returns a pre-run function that validates authentication before command execution. If the Factory has an API client override (test mode), authentication is skipped.

func ParseMSTimestamp added in v0.11.0

func ParseMSTimestamp(ms string) time.Time

ParseMSTimestamp parses a millisecond Unix timestamp string into a time.Time.

func ResolveCurrentSprintListID added in v0.11.0

func ResolveCurrentSprintListID(ctx context.Context, client *api.Client, folderID string) (string, error)

ResolveCurrentSprintListID finds the current sprint's list ID in the given folder. Returns ("", nil) if no sprint matches today's date.

func ValidateStatus added in v0.9.0

func ValidateStatus(client *api.Client, spaceID, status string, w io.Writer) (string, error)

ValidateStatus validates a status string against the available statuses for a task's list, falling back to space-level statuses if the list has no custom overrides. If the status fuzzy-matches, it returns the matched value and prints a warning to w. If no match, it returns an error with available statuses. If validation cannot be performed (e.g. network error), the original status is returned unchanged.

func ValidateStatusFromLists added in v0.17.0

func ValidateStatusFromLists(client *api.Client, spaceID string, listStatuses []string, status string, w io.Writer) (string, error)

ValidateStatusFromLists validates a status string against pre-fetched list statuses, falling back to space-level statuses if no list statuses are provided.

func ValidateStatusWithList added in v0.17.0

func ValidateStatusWithList(client *api.Client, spaceID, listID, status string, w io.Writer) (string, error)

ValidateStatusWithList validates a status string against the available statuses for a list, falling back to space-level statuses if the list has no custom status overrides.

func ValidateTags added in v0.10.0

func ValidateTags(client *api.Client, spaceID string, tags []string, w io.Writer) []string

ValidateTags validates tag names against the available tags for a space. Unknown tags are warned about and filtered out. Only valid tags are returned. If validation cannot be performed (e.g. network error), all tags are returned unchanged.

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) ApiClient

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

ApiClient returns an authenticated API client (cached after first call).

func (*Factory) Config

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

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

func (*Factory) GitClient

func (f *Factory) GitClient() *gitpkg.Client

GitClient returns a new git client.

func (*Factory) GitContext

func (f *Factory) GitContext() (*gitpkg.RepoContext, error)

GitContext returns the detected git context (cached after first call).

func (*Factory) SetAPIClient added in v0.21.0

func (f *Factory) SetAPIClient(c *api.Client)

SetAPIClient sets a test override for the API client.

func (*Factory) SetConfig added in v0.21.0

func (f *Factory) SetConfig(c *config.Config)

SetConfig sets a test override for the configuration.

func (*Factory) SetGitContext added in v0.21.0

func (f *Factory) SetGitContext(c *gitpkg.RepoContext)

SetGitContext sets a test override for the git context.

type JSONFlags

type JSONFlags struct {
	JSON     bool
	JQ       string
	Raw      bool
	Template string
}

JSONFlags holds the --json, --jq, --raw, 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 RecentTask added in v0.5.0

type RecentTask struct {
	ID         string `json:"id"`
	CustomID   string `json:"custom_id,omitempty"`
	Name       string `json:"name"`
	Status     string `json:"status"`
	ListName   string `json:"list_name"`
	FolderName string `json:"folder_name"`
}

RecentTask represents a recently updated task with location context.

func FetchRecentTasks added in v0.5.0

func FetchRecentTasks(f *Factory, limit int) ([]RecentTask, error)

FetchRecentTasks fetches the current user's recently updated tasks. Uses 2 API calls: one for user identity, one for filtered tasks. Returns up to `limit` tasks ordered by most recently updated.

func FetchRecentTeamTasks added in v0.5.0

func FetchRecentTeamTasks(f *Factory, limit int) ([]RecentTask, error)

FetchRecentTeamTasks fetches recently updated tasks for the whole team (no assignee filter). Uses 1 API call.

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

Jump to

Keyboard shortcuts

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