Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var CreateCmd = &cobra.Command{ Use: "create", Short: "Create a new task", Long: `Create a new task with the specified configuration`, Run: func(cmd *cobra.Command, args []string) { source, _ := cmd.Flags().GetString("from-json") if source != "" { tasks, err := repository.ReadJSONSource[[]models.Task](source) if err != nil { styles.PrintError(fmt.Sprintf("Failed to read source: %v", err)) os.Exit(1) } if err := repository.ImportTasks(tasks); err != nil { styles.PrintError(fmt.Sprintf("Import failed:\n%v", err)) os.Exit(1) } styles.PrintSuccess(fmt.Sprintf("%d task(s) imported successfully!", len(tasks))) os.Exit(0) } p := tea.NewProgram(NewModel()) if _, err := p.Run(); err != nil { os.Exit(1) } }, }
CreateCmd starts the TUI form to create a new task, or imports tasks from JSON when --from-json is set.
var DeleteCmd = &cobra.Command{ Use: "delete <name>", Short: "Delete a task", Long: `Delete a task with the specified name`, Args: cobra.ExactArgs(1), ValidArgsFunction: completeTaskNames, Run: func(cmd *cobra.Command, args []string) { taskName := args[0] if _, err := repository.FindTaskByName(taskName); err != nil { styles.PrintError(fmt.Sprintf("Task '%s' not found", taskName)) return } if err := DeleteTask(taskName); err != nil { styles.PrintError(fmt.Sprintf("Failed to delete task '%s': %v", taskName, err)) return } styles.PrintSuccess(fmt.Sprintf("Task '%s' deleted successfully!", taskName)) }, }
DeleteCmd deletes a task specified by name.
var EditCmd = &cobra.Command{ Use: "edit <name>", Short: "Edit an existing task", Long: `Edit an existing task with the specified name`, Args: cobra.ExactArgs(1), ValidArgsFunction: completeTaskNames, Run: func(cmd *cobra.Command, args []string) { taskName := args[0] task, err := repository.FindTaskByName(taskName) if err != nil { styles.PrintError(fmt.Sprintf("Task '%s' not found: %v", taskName, err)) return } p := tea.NewProgram(NewEditModel(task)) if _, err := p.Run(); err != nil { os.Exit(1) } }, }
EditCmd starts the TUI form to edit an existing task.
var ListCmd = &cobra.Command{ Use: "list", Short: "List all tasks", Long: `Display a list of all configured tasks`, Run: func(cmd *cobra.Command, args []string) { onlyNames, _ := cmd.Flags().GetBool("only-names") if onlyNames { err := listAllTaskNames() if err != nil { fmt.Println("Error listing task names:", err) } return } if err := listAllTasks(); err != nil { fmt.Println("Error listing tasks:", err) } }, }
ListCmd displays the list of configured tasks.
var RunCmd = &cobra.Command{ Use: "run <name>", Short: "Run a task", Long: `Run a task with the specified name`, Args: cobra.ExactArgs(1), ValidArgsFunction: completeTaskNames, Run: func(cmd *cobra.Command, args []string) { taskName := args[0] runner, err := vscode.NewRunner() if err != nil { styles.PrintError(fmt.Sprintf("Failed to create secure runner: %v", err)) return } styles.PrintProgress(fmt.Sprintf("Detected secure VSCode instance, proceeding to run task '%s'...", taskName)) if err := runner.RunTask(taskName); err != nil { styles.PrintError(fmt.Sprintf("Error running task: %v", err)) return } }, }
Functions ¶
func DeleteTask ¶
DeleteTask removes a task from the local configuration file by name.
func FindByName ¶
FindByName retrieves a task by its name from the saved tasks
func NewEditModel ¶
NewEditModel initializes and returns the TUI model for editing an existing task.
Types ¶
type TaskModel ¶
type TaskModel struct {
// contains filtered or unexported fields
}
TaskModel manages the state and logic of the TUI form for creating/editing tasks.
func (*TaskModel) HandleFocus ¶
HandleFocus updates the visual focus and style of the form fields.
func (*TaskModel) HandleInput ¶
HandleInput processes text input and updates the suggestion managers.