cli

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IconSuccess = "✓"
	IconError   = "✗"
	IconWarning = "!"
	IconInfo    = "→"
)

Icons for status messages

Variables

View Source
var (
	ColorSuccess = lipgloss.AdaptiveColor{Dark: "#22c55e", Light: "#16a34a"} // green
	ColorError   = lipgloss.AdaptiveColor{Dark: "#ef4444", Light: "#dc2626"} // red
	ColorWarning = lipgloss.AdaptiveColor{Dark: "#f59e0b", Light: "#d97706"} // amber
	ColorInfo    = lipgloss.AdaptiveColor{Dark: "#3b82f6", Light: "#2563eb"} // blue
	ColorMuted   = lipgloss.AdaptiveColor{Dark: "#6b7280", Light: "#9ca3af"} // gray
	ColorAccent  = lipgloss.AdaptiveColor{Dark: "#a78bfa", Light: "#7c3aed"} // purple for IDs
	ColorURL     = lipgloss.AdaptiveColor{Dark: "#38bdf8", Light: "#0284c7"} // cyan for URLs
)

Adaptive colors that work in both light and dark terminals. First value is for dark terminals, second for light terminals.

View Source
var (
	StyleSuccess = lipgloss.NewStyle().Foreground(ColorSuccess)
	StyleError   = lipgloss.NewStyle().Foreground(ColorError)
	StyleWarning = lipgloss.NewStyle().Foreground(ColorWarning)
	StyleInfo    = lipgloss.NewStyle().Foreground(ColorInfo)
	StyleMuted   = lipgloss.NewStyle().Foreground(ColorMuted)
	StyleID      = lipgloss.NewStyle().Foreground(ColorAccent)
	StyleURL     = lipgloss.NewStyle().Foreground(ColorURL)
	StyleBold    = lipgloss.NewStyle().Bold(true)
)

Reusable text styles

Functions

func Box added in v0.11.0

func Box(content string) string

Box renders content in a bordered box.

func ColorSwatch added in v0.11.0

func ColorSwatch(hexColor string) string

ColorSwatch renders a small color swatch block in the given hex color.

func Fatal

func Fatal(err error)

Fatal prints a styled error and exits.

func LabelValue added in v0.11.0

func LabelValue(label, value string, labelWidth int) string

LabelValue formats a label-value pair with right-aligned label.

func PrintError added in v0.11.0

func PrintError(format string, args ...any)

PrintError prints an error message with a red X to stderr.

func PrintInfo added in v0.11.0

func PrintInfo(format string, args ...any)

PrintInfo prints an info message with a blue arrow to stderr.

func PrintSuccess added in v0.11.0

func PrintSuccess(format string, args ...any)

PrintSuccess prints a success message with a green checkmark to stderr.

func PrintWarning added in v0.11.0

func PrintWarning(format string, args ...any)

PrintWarning prints a warning message with an amber icon to stderr.

func RenderBold added in v0.11.0

func RenderBold(text string) string

RenderBold renders text in bold.

func RenderColumnColor added in v0.11.0

func RenderColumnColor(text, hexColor string) string

RenderColumnColor renders text in the given hex color. Falls back to muted if color is empty or invalid.

func RenderID added in v0.11.0

func RenderID(id string) string

RenderID renders a card/comment ID in accent color.

func RenderMuted added in v0.11.0

func RenderMuted(text string) string

RenderMuted renders text in muted color.

func RenderTypeIndicator added in v0.11.0

func RenderTypeIndicator(value, hexColor string) string

RenderTypeIndicator renders a type indicator value in brackets with its color. Returns empty string if value is empty.

func RenderURL added in v0.11.0

func RenderURL(url string) string

RenderURL renders a URL in the URL color.

func Run

func Run()

Run is the main entry point for the CLI.

func TitleBox added in v0.11.0

func TitleBox(title string) string

TitleBox renders a title in a prominent bordered box.

Types

type AddOutput added in v0.11.0

type AddOutput struct {
	Card  cardJson         `json:"card"`
	Hooks []hookResultJson `json:"hooks,omitempty"`
}

AddOutput wraps a created card and any hook results for JSON output.

func NewAddOutput added in v0.11.0

func NewAddOutput(card *model.Card, hookResults []*service.HookResult) AddOutput

NewAddOutput creates an AddOutput from a card and hook results.

type App

type App struct {
	GitClient     *git.Client
	GlobalStore   store.GlobalStore
	ProjectStore  store.ProjectStore
	Paths         *config.Paths
	BoardStore    store.BoardStore
	CardStore     store.CardStore
	Prompter      prompt.Prompter
	InitService   *service.InitService
	BoardService  *service.BoardService
	CardService   *service.CardService
	AliasService  *service.AliasService
	HookService   *service.HookService
	BoardResolver *resolver.BoardResolver
	CardResolver  *resolver.CardResolver
	ProjectRoot   string
	// UsingGlobalBoard is true when the App was built via -g (targeting the
	// designated global board). Handlers use it to surface the target in output.
	UsingGlobalBoard bool
}

App holds all the dependencies for the CLI. Uses interfaces for testability.

func NewApp

func NewApp(interactive bool) (*App, error)

NewApp creates a new App with all dependencies wired up. If interactive is false, uses NoopPrompter that fails on prompts.

func NewAppWithOptions added in v0.26.0

func NewAppWithOptions(opts AppOptions) (*App, error)

NewAppWithOptions creates a new App, optionally retargeted at the designated global board instead of the project discovered from the cwd.

func NewAppWithoutDiscovery added in v0.6.1

func NewAppWithoutDiscovery() (*App, error)

NewAppWithoutDiscovery creates a minimal App without running project discovery. Used by init command when discovery fails due to stale global config.

func (*App) GetAuthor added in v0.7.1

func (a *App) GetAuthor() (string, error)

GetAuthor returns the username for authorship fields (card creator, comment author).

func (*App) PrintGlobalTarget added in v0.26.0

func (a *App) PrintGlobalTarget(boardName string)

PrintGlobalTarget surfaces which global board a command acted on, so a mistaken -g designation is immediately visible. No-op outside global mode. Writes to stderr (like other status output), so it never pollutes --json.

func (*App) RequireKan

func (a *App) RequireKan() error

RequireKan ensures Kan is initialized in the current project.

func (*App) ResolveCardWithBoard added in v0.21.0

func (a *App) ResolveCardWithBoard(explicitBoard, idOrAlias string, interactive bool) (*CardResolution, error)

ResolveCardWithBoard resolves both the board and card for commands that take a card ID/alias. When no board is specified and there are fewer than MaxBoardsForCrossSearch boards, searches across all boards automatically.

type AppOptions added in v0.26.0

type AppOptions struct {
	// Interactive selects the HuhPrompter (vs the NoopPrompter that fails on prompts).
	Interactive bool
	// UseGlobalBoard bypasses cwd discovery and targets the designated global
	// board's project instead (see `kan global set`). Errors if none is set.
	UseGlobalBoard bool
}

AppOptions configures how NewAppWithOptions wires up the App.

type BoardDescribeColumnInfo added in v0.14.0

type BoardDescribeColumnInfo struct {
	Name        string `json:"name"`
	Color       string `json:"color"`
	Description string `json:"description,omitempty"`
	Limit       int    `json:"limit,omitempty"`
	CardCount   int    `json:"card_count"`
	IsDefault   bool   `json:"is_default"`
}

BoardDescribeColumnInfo contains column data for board describe JSON output.

type BoardDescribeInfo added in v0.14.0

type BoardDescribeInfo struct {
	Name          string                             `json:"name"`
	Schema        string                             `json:"schema"`
	DefaultColumn string                             `json:"default_column"`
	Columns       []BoardDescribeColumnInfo          `json:"columns"`
	CustomFields  map[string]model.CustomFieldSchema `json:"custom_fields,omitempty"`
	CardDisplay   model.CardDisplayConfig            `json:"card_display,omitempty"`
	LinkRules     []model.LinkRule                   `json:"link_rules,omitempty"`
	PatternHooks  []model.PatternHook                `json:"pattern_hooks,omitempty"`
}

BoardDescribeInfo contains full board documentation for JSON output. Kept in sync with model.BoardConfig by TestBoardDescribeFieldSync.

type BoardDescribeOutput added in v0.14.0

type BoardDescribeOutput struct {
	Board BoardDescribeInfo `json:"board"`
}

BoardDescribeOutput wraps board describe data for JSON output.

type BoardsOutput added in v0.11.0

type BoardsOutput struct {
	Boards []string `json:"boards"`
}

BoardsOutput wraps a list of board names for JSON output.

func NewBoardsOutput added in v0.11.0

func NewBoardsOutput(boards []string) BoardsOutput

NewBoardsOutput creates a BoardsOutput from board names. Always returns an empty array (not null) when there are no boards.

type CardOutput added in v0.11.0

type CardOutput struct {
	Card cardJson `json:"card"`
}

CardOutput wraps a single card for JSON output.

func NewCardOutput added in v0.11.0

func NewCardOutput(card *model.Card) CardOutput

NewCardOutput creates a CardOutput from a model.Card.

type CardResolution added in v0.21.0

type CardResolution struct {
	Card      *model.Card
	BoardName string
	// CrossBoard is true when the card was found via cross-board search
	// (no explicit board flag, no single board, no default). Callers can use
	// this to decide whether to print which board the card was found in.
	CrossBoard bool
	// MultipleBoards is true when the project has more than one board.
	// Used by callers to decide whether to show board context in output.
	MultipleBoards bool
}

CardResolution holds the result of resolving a card along with its board.

type ColumnInfo added in v0.11.0

type ColumnInfo struct {
	Name        string `json:"name"`
	Color       string `json:"color"`
	Description string `json:"description,omitempty"`
	Limit       int    `json:"limit,omitempty"`
	CardCount   int    `json:"card_count"`
}

ColumnInfo represents column data for JSON output.

type ColumnsOutput added in v0.11.0

type ColumnsOutput struct {
	Columns []ColumnInfo `json:"columns"`
}

ColumnsOutput wraps a list of columns for JSON output.

func NewColumnsOutput added in v0.11.0

func NewColumnsOutput(columns []ColumnInfo) ColumnsOutput

NewColumnsOutput creates a ColumnsOutput from column info. Always returns an empty array (not null) when there are no columns.

type CommandContext

type CommandContext struct {
	// Global flags
	NonInteractive *bool
	Json           *bool

	// completion command
	CompletionUsed  *bool
	CompletionShell *string
	RootCmd         *ra.Cmd

	// init command
	InitUsed        *bool
	InitLocation    *string
	InitColumns     *string
	InitName        *string
	InitProjectName *string

	// board command
	BoardUsed       *bool
	BoardCreateUsed *bool
	BoardCreateName *string
	BoardListUsed   *bool

	// board describe
	BoardDescribeUsed  *bool
	BoardDescribeName  *string
	BoardDescribeBoard *string

	// delete command
	DeleteUsed   *bool
	DeleteCard   *string
	DeleteBoard  *string
	DeleteGlobal *bool

	// board delete
	BoardDeleteUsed *bool
	BoardDeleteName *string

	// add command
	AddUsed        *bool
	AddTitle       *string
	AddDescription *string
	AddBoard       *string
	AddColumn      *string
	AddParent      *string
	AddPosition    *int
	AddBefore      *string
	AddAfter       *string
	AddFields      *[]string
	AddStrict      *bool
	AddGlobal      *bool

	// show command
	ShowUsed   *bool
	ShowCard   *string
	ShowBoard  *string
	ShowGlobal *bool

	// history command
	HistoryUsed   *bool
	HistoryCard   *string
	HistoryBoard  *string
	HistoryGlobal *bool

	// list command
	ListUsed   *bool
	ListBoard  *string
	ListColumn *string
	ListGlobal *bool

	// edit command
	EditUsed        *bool
	EditCard        *string
	EditBoard       *string
	EditTitle       *string
	EditDescription *string
	EditColumn      *string
	EditParent      *string
	EditPosition    *int
	EditBefore      *string
	EditAfter       *string
	EditAlias       *string
	EditFields      *[]string
	EditStrict      *bool
	EditGlobal      *bool

	// serve command
	ServeUsed   *bool
	ServePort   *int
	ServeNoOpen *bool

	// migrate command
	MigrateUsed   *bool
	MigrateDryRun *bool
	MigrateAll    *bool

	// column command
	ColumnUsed *bool

	// column add
	ColumnAddUsed        *bool
	ColumnAddName        *string
	ColumnAddColor       *string
	ColumnAddDescription *string
	ColumnAddPosition    *int
	ColumnAddLimit       *int
	ColumnAddBoard       *string

	// column delete
	ColumnDeleteUsed  *bool
	ColumnDeleteName  *string
	ColumnDeleteBoard *string

	// column rename
	ColumnRenameUsed  *bool
	ColumnRenameOld   *string
	ColumnRenameNew   *string
	ColumnRenameBoard *string

	// column edit
	ColumnEditUsed        *bool
	ColumnEditName        *string
	ColumnEditColor       *string
	ColumnEditDescription *string
	ColumnEditLimit       *int
	ColumnEditBoard       *string

	// column list
	ColumnListUsed  *bool
	ColumnListBoard *string

	// column move
	ColumnMoveUsed     *bool
	ColumnMoveName     *string
	ColumnMovePosition *int
	ColumnMoveAfter    *string
	ColumnMoveBoard    *string

	// comment command
	CommentUsed *bool

	// comment add
	CommentAddUsed   *bool
	CommentAddCard   *string
	CommentAddBody   *string
	CommentAddBoard  *string
	CommentAddGlobal *bool

	// comment edit
	CommentEditUsed   *bool
	CommentEditID     *string
	CommentEditBody   *string
	CommentEditBoard  *string
	CommentEditGlobal *bool

	// comment delete
	CommentDeleteUsed   *bool
	CommentDeleteID     *string
	CommentDeleteBoard  *string
	CommentDeleteGlobal *bool

	// doctor command
	DoctorUsed   *bool
	DoctorFix    *bool
	DoctorDryRun *bool
	DoctorBoard  *string

	// commit command
	CommitUsed    *bool
	CommitMessage *string

	// global command
	GlobalUsed *bool

	// global set
	GlobalSetUsed  *bool
	GlobalSetBoard *string

	// global show
	GlobalShowUsed *bool

	// global unset
	GlobalUnsetUsed *bool
}

CommandContext holds parsed values and used flags for all commands.

type CommentOutput added in v0.11.0

type CommentOutput struct {
	Comment *model.Comment `json:"comment"`
}

CommentOutput wraps a single comment for JSON output.

type ListOutput added in v0.11.0

type ListOutput struct {
	Cards []cardJson `json:"cards"`
}

ListOutput wraps a list of cards for JSON output.

func NewListOutput added in v0.11.0

func NewListOutput(cards []*model.Card) ListOutput

NewListOutput creates a ListOutput from a slice of model.Card. Always returns an empty array (not null) when there are no cards.

Jump to

Keyboard shortcuts

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