Documentation
¶
Index ¶
- Constants
- Variables
- func Box(content string) string
- func ColorSwatch(hexColor string) string
- func Fatal(err error)
- func LabelValue(label, value string, labelWidth int) string
- func PrintError(format string, args ...any)
- func PrintInfo(format string, args ...any)
- func PrintSuccess(format string, args ...any)
- func PrintWarning(format string, args ...any)
- func RenderBold(text string) string
- func RenderColumnColor(text, hexColor string) string
- func RenderID(id string) string
- func RenderMuted(text string) string
- func RenderTypeIndicator(value, hexColor string) string
- func RenderURL(url string) string
- func Run()
- func TitleBox(title string) string
- type AddOutput
- type App
- type AppOptions
- type BoardDescribeColumnInfo
- type BoardDescribeInfo
- type BoardDescribeOutput
- type BoardsOutput
- type CardOutput
- type CardResolution
- type ColumnInfo
- type ColumnsOutput
- type CommandContext
- type CommentOutput
- type ListOutput
Constants ¶
const ( IconSuccess = "✓" IconError = "✗" IconWarning = "!" IconInfo = "→" )
Icons for status messages
Variables ¶
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.
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 ColorSwatch ¶ added in v0.11.0
ColorSwatch renders a small color swatch block in the given hex color.
func LabelValue ¶ added in v0.11.0
LabelValue formats a label-value pair with right-aligned label.
func PrintError ¶ added in v0.11.0
PrintError prints an error message with a red X to stderr.
func PrintSuccess ¶ added in v0.11.0
PrintSuccess prints a success message with a green checkmark to stderr.
func PrintWarning ¶ added in v0.11.0
PrintWarning prints a warning message with an amber icon to stderr.
func RenderBold ¶ added in v0.11.0
RenderBold renders text in bold.
func RenderColumnColor ¶ added in v0.11.0
RenderColumnColor renders text in the given hex color. Falls back to muted if color is empty or invalid.
func RenderMuted ¶ added in v0.11.0
RenderMuted renders text in muted color.
func RenderTypeIndicator ¶ added in v0.11.0
RenderTypeIndicator renders a type indicator value in brackets with its color. Returns empty string if value is empty.
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 ¶
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
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
GetAuthor returns the username for authorship fields (card creator, comment author).
func (*App) PrintGlobalTarget ¶ added in v0.26.0
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 ¶
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
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.