diff options
| author | Paul Bütow <1224732+snonux@users.noreply.github.com> | 2025-06-22 16:58:00 +0300 |
|---|---|---|
| committer | Paul Bütow <1224732+snonux@users.noreply.github.com> | 2025-06-22 16:58:00 +0300 |
| commit | 8a83fbf747bda27f5859ad84c2f20a9afb753e39 (patch) | |
| tree | e2585f906485e89f6d4417a5d1d3d04f9c442ce4 /internal | |
| parent | b140c36cd8bb3d20c7211fe672b9d5674c9f0d3b (diff) | |
Clean up unused RunArgs comments
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/task/task.go | 18 | ||||
| -rw-r--r-- | internal/ui/table.go | 61 | ||||
| -rw-r--r-- | internal/ui/table_test.go | 51 |
3 files changed, 1 insertions, 129 deletions
diff --git a/internal/task/task.go b/internal/task/task.go index 5f19482..b20eef0 100644 --- a/internal/task/task.go +++ b/internal/task/task.go @@ -86,24 +86,6 @@ func AddLine(line string) error { return AddArgs(fields) } -// RunArgs executes "task" with the given arguments. Each item in args is -// passed as a separate command-line argument. -func RunArgs(args []string) error { - cmd := exec.Command("task", args...) - return cmd.Run() -} - -// RunLine splits the provided line into shell words and executes "task" with -// the resulting arguments. This allows callers to run arbitrary Taskwarrior -// commands directly. -func RunLine(line string) error { - fields, err := shlex.Split(line) - if err != nil { - return err - } - return RunArgs(fields) -} - // Export retrieves all tasks using `task export rc.json.array=off` and parses // the JSON output into a slice of Task structs. // Export retrieves tasks using `task <filter> export rc.json.array=off` and parses diff --git a/internal/ui/table.go b/internal/ui/table.go index 480936c..c3e1748 100644 --- a/internal/ui/table.go +++ b/internal/ui/table.go @@ -64,9 +64,6 @@ type Model struct { addingTask bool addInput textinput.Model - runningTask bool - taskInput textinput.Model - searching bool searchInput textinput.Model searchRegex *regexp.Regexp @@ -170,9 +167,6 @@ func New(filters []string) (Model, error) { m.addInput = textinput.New() m.addInput.Prompt = "add: " - m.taskInput = textinput.New() - m.taskInput.Prompt = "task: " - m.defaultTheme = DefaultTheme() m.theme = m.defaultTheme @@ -523,46 +517,6 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { m.addInput, cmd = m.addInput.Update(msg) return m, cmd } - if m.runningTask { - switch msg.Type { - case tea.KeyEnter: - oldIDs := make(map[int]struct{}) - for _, tsk := range m.tasks { - oldIDs[tsk.ID] = struct{}{} - } - task.RunLine(m.taskInput.Value()) - m.runningTask = false - m.taskInput.Blur() - m.reload() - var newID int - row := -1 - for i, tsk := range m.tasks { - if _, ok := oldIDs[tsk.ID]; !ok { - newID = tsk.ID - row = i - break - } - } - m.updateTableHeight() - if row >= 0 { - prevRow := m.tbl.Cursor() - prevCol := m.tbl.ColumnCursor() - m.tbl.SetCursor(row) - m.tbl.SetColumnCursor(7) - m.updateSelectionHighlight(prevRow, m.tbl.Cursor(), prevCol, m.tbl.ColumnCursor()) - return m, m.startBlink(newID, false) - } - return m, nil - case tea.KeyEsc: - m.runningTask = false - m.taskInput.Blur() - m.updateTableHeight() - return m, nil - } - var cmd tea.Cmd - m.taskInput, cmd = m.taskInput.Update(msg) - return m, cmd - } if m.searching { switch msg.Type { case tea.KeyEnter: @@ -756,12 +710,6 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { m.addInput.Focus() m.updateTableHeight() return m, nil - case "T": - m.runningTask = true - m.taskInput.SetValue("") - m.taskInput.Focus() - m.updateTableHeight() - return m, nil case "t": if row := m.tbl.SelectedRow(); row != nil { idStr := ansi.Strip(row[1]) @@ -905,7 +853,6 @@ func (m Model) View() string { m.tbl.HelpView(), "enter/i: edit or expand cell", "E: edit task", - "T: run task command", "+: add task", "s: toggle start/stop", "d: mark task done", @@ -987,12 +934,6 @@ func (m Model) View() string { m.addInput.View(), ) } - if m.runningTask { - view = lipgloss.JoinVertical(lipgloss.Left, - view, - m.taskInput.View(), - ) - } if m.searching { view = lipgloss.JoinVertical(lipgloss.Left, view, @@ -1306,7 +1247,7 @@ func (m *Model) updateTableHeight() { if m.cellExpanded { h-- } - if m.annotating || m.dueEditing || m.prioritySelecting || m.searching || m.descEditing || m.tagsEditing || m.recurEditing || m.filterEditing || m.addingTask || m.runningTask { + if m.annotating || m.dueEditing || m.prioritySelecting || m.searching || m.descEditing || m.tagsEditing || m.recurEditing || m.filterEditing || m.addingTask { h-- } if h < 1 { diff --git a/internal/ui/table_test.go b/internal/ui/table_test.go index d94243b..365180c 100644 --- a/internal/ui/table_test.go +++ b/internal/ui/table_test.go @@ -493,57 +493,6 @@ func TestAddHotkey(t *testing.T) { } } -func TestTaskHotkey(t *testing.T) { - tmp := t.TempDir() - taskPath := filepath.Join(tmp, "task") - cmdFile := filepath.Join(tmp, "cmd.txt") - - script := "#!/bin/sh\n" + - "if echo \"$@\" | grep -q export; then\n" + - " echo '{\"id\":1,\"uuid\":\"x\",\"description\":\"d\",\"status\":\"pending\",\"entry\":\"\",\"priority\":\"\",\"urgency\":0}'\n" + - " exit 0\n" + - "fi\n" + - "echo \"$@\" > " + cmdFile + "\n" - - if err := os.WriteFile(taskPath, []byte(script), 0o755); err != nil { - t.Fatal(err) - } - - origPath := os.Getenv("PATH") - os.Setenv("PATH", tmp+":"+origPath) - t.Cleanup(func() { os.Setenv("PATH", origPath) }) - - os.Setenv("TASKDATA", tmp) - os.Setenv("TASKRC", "/dev/null") - t.Cleanup(func() { - os.Unsetenv("TASKDATA") - os.Unsetenv("TASKRC") - }) - - m, err := New(nil) - if err != nil { - t.Fatalf("New: %v", err) - } - - mv, _ := m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'T'}}) - m = mv.(Model) - for _, r := range "+bg modify +huhu" { - mv, _ = m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{r}}) - m = mv.(Model) - } - mv, _ = m.Update(tea.KeyMsg{Type: tea.KeyEnter}) - m = mv.(Model) - - data, err := os.ReadFile(cmdFile) - if err != nil { - t.Fatalf("read cmd: %v", err) - } - - if strings.TrimSpace(string(data)) != "+bg modify +huhu" { - t.Fatalf("task not called: %q", data) - } -} - func TestNavigationHotkeys(t *testing.T) { tmp := t.TempDir() taskPath := filepath.Join(tmp, "task") |
