summaryrefslogtreecommitdiff
path: root/internal/askcli/taskexport.go
blob: ca67ef500064be1022e1dd188cc84341c0c57d50 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package askcli

import (
	"encoding/json"
	"fmt"
	"io"
)

type TaskExport struct {
	UUID        string   `json:"uuid"`
	Description string   `json:"description"`
	Status      string   `json:"status"`
	Priority    string   `json:"priority"`
	Tags        []string `json:"tags"`
	Start       string   `json:"start,omitempty"`
	Urgency     float64  `json:"urgency"`
	Depends     []string `json:"depends"`
	Annotations []struct {
		Description string `json:"description"`
		Entry       string `json:"entry"`
	} `json:"annotations"`
}

func ParseTaskExport(r io.Reader) ([]TaskExport, error) {
	data, err := io.ReadAll(r)
	if err != nil {
		return nil, fmt.Errorf("failed to read task export data: %w", err)
	}
	var tasks []TaskExport
	if err := json.Unmarshal(data, &tasks); err != nil {
		return nil, fmt.Errorf("failed to parse task export JSON: %w", err)
	}
	return tasks, nil
}