This repository has been archived on 2025-10-30. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
gitwarrior/cmd/gitw/main.go
Yves Biener 6f27c0a4d9 add(taskwarrior): get exported taskwarrior tasks
This implementation uses a filter struct to create taskwarrior filters
(like you would do in the command line) to export the filtered tasks
into json which are parsed as go structs.
2023-10-20 12:50:18 +02:00

92 lines
2.4 KiB
Go

package main
import (
"fmt"
"os"
"gitea.yves-biener.de/yves-biener/gitwarrior/internal/gitea"
"gitea.yves-biener.de/yves-biener/gitwarrior/internal/gitw"
"gitea.yves-biener.de/yves-biener/gitwarrior/internal/taskwarrior"
)
func main() {
// TODO: server url may be also be derived from the git configuration?
server := gitea.NewGitea("https://gitea.yves-biener.de")
repository, err := gitw.Discover()
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(-1)
}
repository, err = server.VerifyRepository(repository)
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(-1)
}
fmt.Printf("%#v\n", repository)
fmt.Println("---")
issue, err := server.GetIssue(repository, 1)
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(-1)
}
milestone, err := server.GetMilestone(repository, 1)
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(-1)
}
comments, err := server.GetComments(repository)
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(-1)
}
fmt.Printf("%#v\n", issue)
fmt.Println("---")
fmt.Printf("%#v\n", milestone)
fmt.Println("---")
for _, comment := range comments {
// NOTE: filter comments to only include comments which are related to the current issue
// Order them by their Id's as that's the order they are in the issue (most likely)
if comment.Issue_url == issue.Html_url {
fmt.Printf("%#v\n", comment)
}
}
var filter taskwarrior.Filter
filter.IncludeProjects("notes")
tasks, err := taskwarrior.GetTasks(filter)
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(-1)
}
for _, task := range tasks {
fmt.Printf("%#v\n", task)
}
fmt.Println("---")
filter.Reset()
filter.IncludeIds(1, 2, 3)
tasks, err = taskwarrior.GetTasks(filter)
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(-1)
}
for _, task := range tasks {
fmt.Printf("%#v\n", task)
}
fmt.Println("---")
// necessary configurations (see config file gitw.json)
// - access code for gitea
// - configuration for taskwarrior settings?
// cli actions and parameters
// - action: diff (i.e. what has changed between the current state of the taskwarrior tasks and the git issues / milestones)
// - action: status (are there changes between the taskwarrior tasks and the gitea issues / milestones, that would require a sync)
// - action: sync (synch diffs between taskwarrior tasks and gitea issues / milestones)
// - parameter: --dry-run (do only show changes that would be applied but do not apply them)
}