Documentation
¶
Overview ¶
Package resolve provides interactive prompts for resolving missing CLI options. When required options like --account or --project are not specified, the resolver interactively prompts the user to select from available options.
Index ¶
- func PersistAccountID(accountID, scope string) error
- func PersistDefaultProfile(profileName, scope string) error
- func PersistProjectID(projectID, scope string) error
- func PersistTodolistID(todolistID, scope string) error
- func PersistValue(key, value, scope string) error
- func PromptAndPersist(opt PersistOption) (bool, error)
- func PromptAndPersistAccountID(accountID string) (bool, error)
- func PromptAndPersistDefaultProfile(profileName string) (bool, error)
- func PromptAndPersistProjectID(projectID string) (bool, error)
- func PromptAndPersistTodolistID(todolistID string) (bool, error)
- type CommentTarget
- type CommentThread
- type Context
- type DockTool
- type DockToolResult
- type Flags
- type Option
- type PersistOption
- type ResolvedSource
- type ResolvedValue
- type Resolver
- func (r *Resolver) Account(ctx context.Context) (*ResolvedValue, error)
- func (r *Resolver) AccountWithPersist(ctx context.Context) (*ResolvedValue, error)
- func (r *Resolver) Auth() *auth.Manager
- func (r *Resolver) Campfire(ctx context.Context, projectID, explicitID string) (*DockToolResult, error)
- func (r *Resolver) Comment(ctx context.Context, onFlag string, projectID string) (*CommentTarget, error)
- func (r *Resolver) Config() *config.Config
- func (r *Resolver) DockTool(ctx context.Context, projectID, dockName, explicitID, friendlyName string) (*DockToolResult, error)
- func (r *Resolver) Flags() *Flags
- func (r *Resolver) Inbox(ctx context.Context, projectID, explicitID string) (*DockToolResult, error)
- func (r *Resolver) IsInteractive() bool
- func (r *Resolver) MessageBoard(ctx context.Context, projectID, explicitID string) (*DockToolResult, error)
- func (r *Resolver) Person(ctx context.Context) (*ResolvedValue, error)
- func (r *Resolver) PersonInProject(ctx context.Context, projectID string) (*ResolvedValue, error)
- func (r *Resolver) Project(ctx context.Context) (*ResolvedValue, error)
- func (r *Resolver) ProjectWithPersist(ctx context.Context) (*ResolvedValue, error)
- func (r *Resolver) Questionnaire(ctx context.Context, projectID, explicitID string) (*DockToolResult, error)
- func (r *Resolver) SDK() *basecamp.Client
- func (r *Resolver) Schedule(ctx context.Context, projectID, explicitID string) (*DockToolResult, error)
- func (r *Resolver) Styles() *tui.Styles
- func (r *Resolver) Todolist(ctx context.Context, projectID string) (*ResolvedValue, error)
- func (r *Resolver) TodolistWithPersist(ctx context.Context, projectID string) (*ResolvedValue, error)
- func (r *Resolver) Todoset(ctx context.Context, projectID, explicitID string) (*DockToolResult, error)
- func (r *Resolver) Vault(ctx context.Context, projectID, explicitID string) (*DockToolResult, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PersistAccountID ¶
PersistAccountID is a convenience function for persisting an account ID.
func PersistDefaultProfile ¶
PersistDefaultProfile is a convenience function for persisting a default profile.
func PersistProjectID ¶
PersistProjectID is a convenience function for persisting a project ID.
func PersistTodolistID ¶
PersistTodolistID is a convenience function for persisting a todolist ID.
func PersistValue ¶
PersistValue saves a config value to the specified scope.
func PromptAndPersist ¶
func PromptAndPersist(opt PersistOption) (bool, error)
PromptAndPersist asks the user if they want to save a value as default, and if so, which scope to save it in. Returns true if the value was saved.
func PromptAndPersistAccountID ¶
PromptAndPersistAccountID prompts the user to save an account ID.
func PromptAndPersistDefaultProfile ¶
PromptAndPersistDefaultProfile prompts the user to save a default profile.
func PromptAndPersistProjectID ¶
PromptAndPersistProjectID prompts the user to save a project ID.
func PromptAndPersistTodolistID ¶
PromptAndPersistTodolistID prompts the user to save a todolist ID.
Types ¶
type CommentTarget ¶
CommentTarget holds the resolved target for a comment.
type CommentThread ¶
type CommentThread struct {
Recording *basecamp.Recording
Comments []basecamp.Comment
// contains filtered or unexported fields
}
CommentThread represents a thread of comments on a recording.
func FetchCommentThread ¶
func FetchCommentThread(ctx context.Context, r *Resolver, projectID, recordingID int64) (*CommentThread, error)
FetchCommentThread fetches and returns a comment thread for a recording.
func NewCommentThread ¶
func NewCommentThread(recording *basecamp.Recording, comments []basecamp.Comment) *CommentThread
NewCommentThread creates a new comment thread view.
func (*CommentThread) Render ¶
func (ct *CommentThread) Render() string
Render returns a formatted string representation of the comment thread.
type Context ¶
Context is a helper type for passing context through resolution chains.
func NewContext ¶
NewContext creates a new resolution context.
type DockTool ¶
type DockTool struct {
Name string `json:"name"`
Title string `json:"title"`
ID int64 `json:"id"`
Enabled bool `json:"enabled"`
}
DockTool represents a tool in a project's dock.
type DockToolResult ¶
type DockToolResult struct {
ToolID string
Tool *DockTool
Source ResolvedSource
}
DockToolResult holds the result of dock tool resolution.
type Flags ¶
type Flags struct {
Account string
Project string
Todolist string
// Machine output flags - when any of these are set, interactive prompts are disabled
Agent bool
JSON bool
Quiet bool
IDsOnly bool
Count bool
}
Flags holds the relevant CLI flag values for resolution.
type Option ¶
type Option func(*Resolver)
Option configures a Resolver.
func WithStyles ¶
WithStyles sets custom TUI styles for the resolver.
type PersistOption ¶
type PersistOption struct {
Key string // Config key (e.g., "account_id")
Value string // Value to persist
Scope string // "local" or "global"
}
PersistOption represents a config persistence option.
type ResolvedSource ¶
type ResolvedSource int
ResolvedSource indicates where a resolved value came from.
const ( // SourceFlag means the value came from a CLI flag. SourceFlag ResolvedSource = iota // SourceConfig means the value came from the config file. SourceConfig // SourcePrompt means the value was selected interactively. SourcePrompt // SourceDefault means a default value was used. SourceDefault )
func (ResolvedSource) String ¶
func (s ResolvedSource) String() string
String returns a human-readable description of the source.
type ResolvedValue ¶
type ResolvedValue struct {
Value string
Source ResolvedSource
}
ResolvedValue represents a value that was resolved, along with metadata about how it was resolved.
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
Resolver provides interactive prompts for resolving missing CLI options. It wraps the SDK client and auth manager to fetch available options, then uses TUI components to let the user select interactively.
func (*Resolver) Account ¶
func (r *Resolver) Account(ctx context.Context) (*ResolvedValue, error)
Account resolves the account ID using the following precedence: 1. CLI flag (--account) 2. Config file (account_id) 3. Interactive prompt (if terminal is interactive) 4. Error (if no account can be determined)
Returns the resolved account ID and the source it came from.
func (*Resolver) AccountWithPersist ¶
func (r *Resolver) AccountWithPersist(ctx context.Context) (*ResolvedValue, error)
AccountWithPersist resolves the account ID and optionally prompts to save it. This is useful for commands that want to offer to save the selected account.
func (*Resolver) Campfire ¶
func (r *Resolver) Campfire(ctx context.Context, projectID, explicitID string) (*DockToolResult, error)
Campfire resolves a campfire ID from a project.
func (*Resolver) Comment ¶
func (r *Resolver) Comment(ctx context.Context, onFlag string, projectID string) (*CommentTarget, error)
Comment resolves the target recording for a comment using the following precedence: 1. CLI flag (--on) 2. Interactive prompt (if terminal is interactive) 3. Error (if no target can be determined)
The project must be resolved before calling this method. Returns the resolved recording ID and project ID.
func (*Resolver) DockTool ¶
func (r *Resolver) DockTool(ctx context.Context, projectID, dockName, explicitID, friendlyName string) (*DockToolResult, error)
DockTool resolves a dock tool ID from a project using the following precedence: 1. Explicit ID provided (--campfire, --board, etc.) 2. Single tool of type exists - use it automatically 3. Interactive prompt (if terminal is interactive) 4. Error listing available tools (if not interactive)
func (*Resolver) Inbox ¶
func (r *Resolver) Inbox(ctx context.Context, projectID, explicitID string) (*DockToolResult, error)
Inbox resolves an inbox ID from a project.
func (*Resolver) IsInteractive ¶
IsInteractive returns true if interactive prompts can be shown. This checks both TTY status and machine-output flags. Returns false if any machine-output flag is set (--agent, --json, --quiet, --ids-only, --count) or if stdout is not a terminal.
func (*Resolver) MessageBoard ¶
func (r *Resolver) MessageBoard(ctx context.Context, projectID, explicitID string) (*DockToolResult, error)
MessageBoard resolves a message board ID from a project.
func (*Resolver) Person ¶
func (r *Resolver) Person(ctx context.Context) (*ResolvedValue, error)
Person resolves a person ID interactively. Unlike Account/Project/Todolist, Person doesn't have a config fallback since it's typically used for assignment operations where the user explicitly selects someone.
Returns the resolved person ID and the source it came from.
func (*Resolver) PersonInProject ¶
PersonInProject resolves a person ID interactively from project members. This is useful when you want to limit the selection to people who have access to a specific project.
func (*Resolver) Project ¶
func (r *Resolver) Project(ctx context.Context) (*ResolvedValue, error)
Project resolves the project ID using the following precedence: 1. CLI flag (--project) 2. Config file (project_id) 3. Interactive prompt (if terminal is interactive) 4. Error (if no project can be determined)
The account must be resolved before calling this method. Returns the resolved project ID and the source it came from.
func (*Resolver) ProjectWithPersist ¶
func (r *Resolver) ProjectWithPersist(ctx context.Context) (*ResolvedValue, error)
ProjectWithPersist resolves the project ID and optionally prompts to save it. This is useful for commands that want to offer to save the selected project.
func (*Resolver) Questionnaire ¶
func (r *Resolver) Questionnaire(ctx context.Context, projectID, explicitID string) (*DockToolResult, error)
Questionnaire resolves a questionnaire (Automatic Check-ins) ID from a project.
func (*Resolver) Schedule ¶
func (r *Resolver) Schedule(ctx context.Context, projectID, explicitID string) (*DockToolResult, error)
Schedule resolves a schedule ID from a project.
func (*Resolver) Todolist ¶
Todolist resolves the todolist ID using the following precedence: 1. CLI flag (--todolist) 2. Config file (todolist_id) 3. Auto-select if exactly one todolist exists (non-interactive fallback) 4. Interactive prompt (if terminal is interactive) 5. Error (if no todolist can be determined)
The project must be resolved before calling this method. Returns the resolved todolist ID and the source it came from.
func (*Resolver) TodolistWithPersist ¶
func (r *Resolver) TodolistWithPersist(ctx context.Context, projectID string) (*ResolvedValue, error)
TodolistWithPersist resolves the todolist ID and optionally prompts to save it.