2018-09-03 06:43:00 +00:00
|
|
|
// Copyright 2018 The Gitea Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a MIT-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
2020-09-30 05:11:33 +00:00
|
|
|
"code.gitea.io/tea/cmd/flags"
|
|
|
|
"code.gitea.io/tea/cmd/issues"
|
2020-12-15 17:38:22 +00:00
|
|
|
"code.gitea.io/tea/modules/context"
|
2020-09-30 05:11:33 +00:00
|
|
|
"code.gitea.io/tea/modules/print"
|
|
|
|
"code.gitea.io/tea/modules/utils"
|
2018-09-03 06:43:00 +00:00
|
|
|
|
2020-01-04 17:44:25 +00:00
|
|
|
"github.com/urfave/cli/v2"
|
2018-09-03 06:43:00 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// CmdIssues represents to login a gitea server.
|
|
|
|
var CmdIssues = cli.Command{
|
|
|
|
Name: "issues",
|
2020-12-16 16:47:40 +00:00
|
|
|
Aliases: []string{"issue", "i"},
|
2020-09-27 14:35:53 +00:00
|
|
|
Usage: "List, create and update issues",
|
|
|
|
Description: "List, create and update issues",
|
2020-04-22 16:09:26 +00:00
|
|
|
ArgsUsage: "[<issue index>]",
|
2018-09-03 06:43:00 +00:00
|
|
|
Action: runIssues,
|
2020-01-04 17:44:25 +00:00
|
|
|
Subcommands: []*cli.Command{
|
2020-09-30 05:11:33 +00:00
|
|
|
&issues.CmdIssuesList,
|
|
|
|
&issues.CmdIssuesCreate,
|
|
|
|
&issues.CmdIssuesReopen,
|
|
|
|
&issues.CmdIssuesClose,
|
2018-09-03 06:43:00 +00:00
|
|
|
},
|
2020-09-30 05:11:33 +00:00
|
|
|
Flags: flags.IssuePRFlags,
|
2018-09-03 06:43:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func runIssues(ctx *cli.Context) error {
|
2020-03-29 13:16:06 +00:00
|
|
|
if ctx.Args().Len() == 1 {
|
2020-12-15 17:38:22 +00:00
|
|
|
return runIssueDetail(ctx, ctx.Args().First())
|
2018-09-03 06:43:00 +00:00
|
|
|
}
|
2020-09-30 05:11:33 +00:00
|
|
|
return issues.RunIssuesList(ctx)
|
2018-09-03 06:43:00 +00:00
|
|
|
}
|
|
|
|
|
2020-12-15 17:38:22 +00:00
|
|
|
func runIssueDetail(cmd *cli.Context, index string) error {
|
|
|
|
ctx := context.InitCommand(cmd)
|
|
|
|
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
|
2018-09-03 06:43:00 +00:00
|
|
|
|
2020-09-30 05:11:33 +00:00
|
|
|
idx, err := utils.ArgToIndex(index)
|
2018-09-03 06:43:00 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-12-15 17:38:22 +00:00
|
|
|
issue, _, err := ctx.Login.Client().GetIssue(ctx.Owner, ctx.Repo, idx)
|
2018-09-03 06:43:00 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-09-30 05:11:33 +00:00
|
|
|
print.IssueDetails(issue)
|
2018-09-03 06:43:00 +00:00
|
|
|
return nil
|
|
|
|
}
|