[WIP] Layout
This commit is contained in:
@ -10,9 +10,23 @@ type TWConfig struct {
|
||||
config map[string]string
|
||||
}
|
||||
|
||||
var (
|
||||
defaultConfig = map[string]string{
|
||||
"uda.tasksquire.report.default": "next",
|
||||
}
|
||||
)
|
||||
|
||||
func NewConfig(config []string) *TWConfig {
|
||||
cfg := parseConfig(config)
|
||||
|
||||
for key, value := range defaultConfig {
|
||||
if _, ok := cfg[key]; !ok {
|
||||
cfg[key] = value
|
||||
}
|
||||
}
|
||||
|
||||
return &TWConfig{
|
||||
config: parseConfig(config),
|
||||
config: cfg,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -10,25 +10,25 @@ import (
|
||||
)
|
||||
|
||||
type Task struct {
|
||||
Id int64 `json:"id"`
|
||||
Uuid string `json:"uuid"`
|
||||
Description string `json:"description"`
|
||||
Project string `json:"project"`
|
||||
Priority string `json:"priority"`
|
||||
Status string `json:"status"`
|
||||
Tags []string `json:"tags"`
|
||||
Depends []string `json:"depends"`
|
||||
Urgency float32 `json:"urgency"`
|
||||
Parent string `json:"parent"`
|
||||
Due string `json:"due"`
|
||||
Wait string `json:"wait"`
|
||||
Scheduled string `json:"scheduled"`
|
||||
Until string `json:"until"`
|
||||
Start string `json:"start"`
|
||||
End string `json:"end"`
|
||||
Entry string `json:"entry"`
|
||||
Modified string `json:"modified"`
|
||||
Recur string `json:"recur"`
|
||||
Id int64 `json:"id,omitempty"`
|
||||
Uuid string `json:"uuid,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Project string `json:"project,omitempty"`
|
||||
Priority string `json:"priority,omitempty"`
|
||||
Status string `json:"status,omitempty"`
|
||||
Tags []string `json:"tags,omitempty"`
|
||||
Depends []string `json:"depends,omitempty"`
|
||||
Urgency float32 `json:"urgency,omitempty"`
|
||||
Parent string `json:"parent,omitempty"`
|
||||
Due string `json:"due,omitempty"`
|
||||
Wait string `json:"wait,omitempty"`
|
||||
Scheduled string `json:"scheduled,omitempty"`
|
||||
Until string `json:"until,omitempty"`
|
||||
Start string `json:"start,omitempty"`
|
||||
End string `json:"end,omitempty"`
|
||||
Entry string `json:"entry,omitempty"`
|
||||
Modified string `json:"modified,omitempty"`
|
||||
Recur string `json:"recur,omitempty"`
|
||||
}
|
||||
|
||||
func (t *Task) GetString(fieldWFormat string) string {
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package taskwarrior
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
@ -87,7 +88,7 @@ type TaskWarrior interface {
|
||||
|
||||
GetTasks(report *Report, filter ...string) Tasks
|
||||
AddTask(task *Task) error
|
||||
ModifyTask(task *Task)
|
||||
ImportTask(task *Task)
|
||||
}
|
||||
|
||||
type TaskSquire struct {
|
||||
@ -325,20 +326,20 @@ func (ts *TaskSquire) AddTask(task *Task) error {
|
||||
}
|
||||
|
||||
// TODO error handling
|
||||
func (ts *TaskSquire) ModifyTask(task *Task) {
|
||||
func (ts *TaskSquire) ImportTask(task *Task) {
|
||||
ts.mutex.Lock()
|
||||
defer ts.mutex.Unlock()
|
||||
|
||||
jsonStr, err := json.Marshal(Tasks{task})
|
||||
tasks, err := json.Marshal(Tasks{task})
|
||||
if err != nil {
|
||||
slog.Error("Failed marshalling task:", err)
|
||||
}
|
||||
|
||||
cmd := exec.Command(twBinary, append([]string{"echo", string(jsonStr), "|"}, append(ts.defaultArgs, []string{"import", "-"}...)...)...)
|
||||
cmd := exec.Command(twBinary, append(ts.defaultArgs, []string{"import", "-"}...)...)
|
||||
cmd.Stdin = bytes.NewBuffer(tasks)
|
||||
out, err := cmd.CombinedOutput()
|
||||
strOut := string(out)
|
||||
if err != nil {
|
||||
slog.Error("Failed modifying task:", err, strOut)
|
||||
slog.Error("Failed modifying task:", err, string(out))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user