Documentation
¶
Overview ¶
Package editor provides utilities for interactive editing with $EDITOR.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Edit ¶
Edit opens the given file in $EDITOR (or vi as fallback) and waits for it to exit. Returns nil if the editor exits with status 0, otherwise returns an error.
func RenderTodoTOML ¶
RenderTodoTOML renders the todo data as a TOML string for editing.
Types ¶
type ParsedTodo ¶
type ParsedTodo struct {
Title string `toml:"title"`
Type string `toml:"type"`
Priority int `toml:"priority"`
Status *string `toml:"status"`
ImplementationModel string `toml:"implementation-model"`
CodeReviewModel string `toml:"code-review-model"`
ProjectReviewModel string `toml:"project-review-model"`
Description string
}
ParsedTodo represents the parsed result from the TOML editor output.
func EditTodo ¶
func EditTodo(existing *todo.Todo) (*ParsedTodo, error)
EditTodo opens the editor for a todo and returns the parsed result. For create: pass nil for existing. For update: pass the existing todo.
func EditTodoWithData ¶
func EditTodoWithData(data TodoData) (*ParsedTodo, error)
EditTodoWithData opens the editor with pre-populated data and returns the parsed result.
func EditTodoWithDataRetry ¶
func EditTodoWithDataRetry(data TodoData, prompter todo.Prompter) (*ParsedTodo, error)
EditTodoWithDataRetry opens the editor with pre-populated data and returns the parsed result. If prompter is non-nil and parsing fails, the user is prompted to re-edit the file. This allows recovering from validation errors without losing work.
When prompter is nil (non-interactive use), validation errors are returned immediately and the temp file is deleted (matching prior EditTodoWithData behavior).
When prompter returns an error (e.g., EOF from stdin), the temp file is preserved and its path is printed so the user can recover their work manually.
If the editor fails to launch or exits with non-zero status, the temp file is deleted and the error is returned immediately (no retry prompt). This is reasonable because either the user never saw the content, or they explicitly aborted the edit.
func ParseTodoTOML ¶
func ParseTodoTOML(content string) (*ParsedTodo, error)
ParseTodoTOML parses the TOML content from the editor.
func (*ParsedTodo) ToCreateOptions ¶
func (p *ParsedTodo) ToCreateOptions() todo.CreateOptions
ToCreateOptions converts a ParsedTodo to todo.CreateOptions.
func (*ParsedTodo) ToTodoData ¶ added in v0.0.3
func (p *ParsedTodo) ToTodoData() TodoData
ToTodoData converts a ParsedTodo back to TodoData for re-rendering.
func (*ParsedTodo) ToUpdateOptions ¶
func (p *ParsedTodo) ToUpdateOptions() todo.UpdateOptions
ToUpdateOptions converts a ParsedTodo to todo.UpdateOptions.
type TodoData ¶
type TodoData struct {
// IsUpdate is true when editing an existing todo.
IsUpdate bool
// ID is the todo ID (only for updates).
ID string
// Title is the todo title.
Title string
// Type is the todo type (task, bug, feature, design).
Type string
// Priority is the todo priority (0-4).
Priority int
// Status is the todo status.
Status string
// Description is the todo description.
Description string
// ImplementationModel selects the model for implementation.
ImplementationModel string
// CodeReviewModel selects the model for commit review.
CodeReviewModel string
// ProjectReviewModel selects the model for project review.
ProjectReviewModel string
}
TodoData represents the data used to render the TOML template.
func DataFromTodo ¶
DataFromTodo creates TodoData from an existing todo for editing.
func DefaultCreateData ¶
func DefaultCreateData() TodoData
DefaultCreateData returns TodoData with default values for creating a new todo.