From 3bfae84d32a73e389ae24db3c53e425b178dc6ec Mon Sep 17 00:00:00 2001 From: Norwin Date: Fri, 2 Oct 2020 14:15:18 +0000 Subject: [PATCH] Use Print Package (#214) print issue & URL after issue creation & edit use print package for pull detail Co-authored-by: Norwin Roosen Reviewed-on: https://gitea.com/gitea/tea/pulls/214 Reviewed-by: 6543 <6543@noreply.gitea.io> Reviewed-by: techknowlogick --- cmd/issues/close.go | 11 ++++++++--- cmd/issues/create.go | 8 +++++--- cmd/pulls.go | 11 ++--------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/cmd/issues/close.go b/cmd/issues/close.go index 850dde4..19e61d1 100644 --- a/cmd/issues/close.go +++ b/cmd/issues/close.go @@ -9,6 +9,7 @@ import ( "code.gitea.io/tea/cmd/flags" "code.gitea.io/tea/modules/config" + "code.gitea.io/tea/modules/print" "code.gitea.io/tea/modules/utils" "code.gitea.io/sdk/gitea" @@ -40,7 +41,11 @@ func editIssueState(ctx *cli.Context, opts gitea.EditIssueOption) error { return err } - _, _, err = login.Client().EditIssue(owner, repo, index, opts) - // TODO: print (short)IssueDetails - return err + issue, _, err := login.Client().EditIssue(owner, repo, index, opts) + if err != nil { + return err + } + + print.IssueDetails(issue) + return nil } diff --git a/cmd/issues/create.go b/cmd/issues/create.go index 60b3b21..0ef1b27 100644 --- a/cmd/issues/create.go +++ b/cmd/issues/create.go @@ -5,10 +5,12 @@ package issues import ( + "fmt" "log" "code.gitea.io/tea/cmd/flags" "code.gitea.io/tea/modules/config" + "code.gitea.io/tea/modules/print" "code.gitea.io/sdk/gitea" "github.com/urfave/cli/v2" @@ -37,7 +39,7 @@ var CmdIssuesCreate = cli.Command{ func runIssuesCreate(ctx *cli.Context) error { login, owner, repo := config.InitCommand(flags.GlobalRepoValue, flags.GlobalLoginValue, flags.GlobalRemoteValue) - _, _, err := login.Client().CreateIssue(owner, repo, gitea.CreateIssueOption{ + issue, _, err := login.Client().CreateIssue(owner, repo, gitea.CreateIssueOption{ Title: ctx.String("title"), Body: ctx.String("body"), // TODO: @@ -53,7 +55,7 @@ func runIssuesCreate(ctx *cli.Context) error { log.Fatal(err) } - // TODO: Print IssueDetails - + print.IssueDetails(issue) + fmt.Println(issue.URL) return nil } diff --git a/cmd/pulls.go b/cmd/pulls.go index 7cd8079..ae18da4 100644 --- a/cmd/pulls.go +++ b/cmd/pulls.go @@ -5,11 +5,10 @@ package cmd import ( - "fmt" - "code.gitea.io/tea/cmd/flags" "code.gitea.io/tea/cmd/pulls" "code.gitea.io/tea/modules/config" + "code.gitea.io/tea/modules/print" "code.gitea.io/tea/modules/utils" "github.com/urfave/cli/v2" @@ -51,12 +50,6 @@ func runPullDetail(index string) error { return err } - // TODO: use glamour once #181 is merged - fmt.Printf("#%d %s\n%s created %s\n\n%s\n", pr.Index, - pr.Title, - pr.Poster.UserName, - pr.Created.Format("2006-01-02 15:04:05"), - pr.Body, - ) + print.PullDetails(pr) return nil }