summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/stanuki/main.go21
1 files changed, 16 insertions, 5 deletions
diff --git a/cmd/stanuki/main.go b/cmd/stanuki/main.go
index ea7c5d2..332c1ad 100644
--- a/cmd/stanuki/main.go
+++ b/cmd/stanuki/main.go
@@ -7,20 +7,31 @@ import (
"net/http"
"github.com/xlgmokha/x/pkg/env"
+ "github.com/xlgmokha/x/pkg/serde"
"github.com/xlgmokha/x/pkg/x"
)
+type Issue struct {
+ ID int `json:"id"`
+ IID int `json:"iid"`
+ ProjectID int `json:"project_id"`
+ Title string `json:"title"`
+ Description string `json:"description"`
+}
+
func main() {
token := env.Fetch("GITLAB_TOKEN", "")
- url := "https://gitlab.com/api/v4/groups/4/issues"
+ url := "https://gitlab.com/api/v4/groups/9970/issues"
client := http.Client{}
request := x.Must(http.NewRequestWithContext(context.TODO(), "GET", url, nil))
request.Header.Add("Authorization", fmt.Sprintf("Bearer %v", token))
response := x.Must(client.Do(request))
-
- if response.StatusCode == http.StatusOK {
- } else {
- fmt.Println(response.Status)
+ if env.Fetch("DUMP", "") != "" {
fmt.Println(string(x.Must(io.ReadAll(response.Body))))
+ } else {
+ issues := x.Must(serde.From[[]Issue](response.Body, serde.JSON))
+ for _, issue := range issues {
+ fmt.Printf("%v: %v\n", issue.ID, issue.Title)
+ }
}
}