Use Print Package (#214)
print issue & URL after issue creation & edit use print package for pull detail Co-authored-by: Norwin Roosen <git@nroo.de> Reviewed-on: https://gitea.com/gitea/tea/pulls/214 Reviewed-by: 6543 <6543@noreply.gitea.io> Reviewed-by: techknowlogick <techknowlogick@gitea.io>
This commit is contained in:
parent
c1d725ed34
commit
3bfae84d32
|
@ -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
|
||||
issue, _, err := login.Client().EditIssue(owner, repo, index, opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
print.IssueDetails(issue)
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
11
cmd/pulls.go
11
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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue