@@ -2,13 +2,14 @@ package main
22
33import (
44 "fmt"
5+ "log"
6+ "os/exec"
7+ "strings"
8+
59 "github.com/ddliu/go-httpclient"
610 "github.com/iancoleman/strcase"
711 "github.com/manifoldco/promptui"
812 "github.com/urfave/cli/v2"
9- "log"
10- "os/exec"
11- "strings"
1213)
1314
1415type Task struct {
@@ -63,21 +64,8 @@ var GitCommand = &cli.Command{
6364 return err
6465 }
6566
66- tokenRes , err := httpclient .Post ("https://quire.io/oauth/token" , map [string ]string {
67- "grant_type" : "authorization_code" ,
68- "code" : conf .QuireAuthToken ,
69- "client_id" : conf .ClientId ,
70- "client_secret" : conf .ClientSecret ,
71- })
72- defer tokenRes .Body .Close ()
73-
74- bodyString , err := ReadBody (tokenRes )
75- if err != nil {
76- return err
77- }
78-
7967 httpclient .Defaults (httpclient.Map {
80- "Authorization" : fmt .Sprintf ("%s %s" , bodyString [ "token_type" ], bodyString [ "access_token" ] ),
68+ "Authorization" : fmt .Sprintf ("%s %s" , conf . TokenType , conf . AccessToken ),
8169 })
8270
8371 projRes , err := httpclient .Get (fmt .Sprintf ("https://quire.io/api/task/list/id/%s" , c .String ("projectId" )))
@@ -149,8 +137,7 @@ var GitCommand = &cli.Command{
149137{{ "Name:" }} {{ .Name }}
150138{{ "Id:" }} {{ .Id }}
151139{{ "Status:" }} {{ .Status }}%
152- {{ "Assigned to:" }} {{ .ListAssignees }}
153- {{ "Description:" }} {{ .Description }}` ,
140+ {{ "Assigned to:" }} {{ .ListAssignees }}` ,
154141 }
155142
156143 prompt := promptui.Select {
@@ -175,16 +162,18 @@ var GitCommand = &cli.Command{
175162
176163 branchName := fmt .Sprintf ("%s/%.0f-%s" , strcase .ToKebab (task .ListAssignees ()), task .Id , strcase .ToKebab (task .Name ))
177164
178- log .Printf ("creating branch %q based on %q" , branchName , c .String ("projectId " ))
165+ log .Printf ("creating branch %q based on %q" , branchName , c .String ("from " ))
179166
180- err = exec .Command ("git" , "checkout" , "-b" , branchName , c .String ("projectId " )).Run ()
167+ err = exec .Command ("git" , "checkout" , "-b" , branchName , c .String ("from " )).Run ()
181168 if err != nil {
169+ log .Fatalln (err )
182170 return err
183171 }
184172
185173 log .Println ("updating task status" )
186174 _ , err = httpclient .PutJson (fmt .Sprintf ("https://quire.io/api/task/id/%s/%.0f" , c .String ("projectId" ), task .Id ), `{"status": 15}` )
187175 if err != nil {
176+ log .Fatalln (err )
188177 return err
189178 }
190179
0 commit comments