2018-09-03 02:43:00 -04: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 01:11:33 -04:00
|
|
|
"code.gitea.io/tea/cmd/flags"
|
|
|
|
"code.gitea.io/tea/cmd/issues"
|
2020-12-15 12:38:22 -05:00
|
|
|
"code.gitea.io/tea/modules/context"
|
2020-09-30 01:11:33 -04:00
|
|
|
"code.gitea.io/tea/modules/print"
|
|
|
|
"code.gitea.io/tea/modules/utils"
|
2018-09-03 02:43:00 -04:00
|
|
|
|
2020-01-04 12:44:25 -05:00
|
|
|
"github.com/urfave/cli/v2"
|
2018-09-03 02:43:00 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
// CmdIssues represents to login a gitea server.
|
|
|
|
var CmdIssues = cli.Command{
|
|
|
|
Name: "issues",
|
2020-12-16 11:47:40 -05:00
|
|
|
Aliases: []string{"issue", "i"},
|
2020-12-21 08:37:20 -05:00
|
|
|
Category: catEntities,
|
2020-09-27 10:35:53 -04:00
|
|
|
Usage: "List, create and update issues",
|
|
|
|
Description: "List, create and update issues",
|
2020-04-22 12:09:26 -04:00
|
|
|
ArgsUsage: "[<issue index>]",
|
2018-09-03 02:43:00 -04:00
|
|
|
Action: runIssues,
|
2020-01-04 12:44:25 -05:00
|
|
|
Subcommands: []*cli.Command{
|
2020-09-30 01:11:33 -04:00
|
|
|
&issues.CmdIssuesList,
|
|
|
|
&issues.CmdIssuesCreate,
|
|
|
|
&issues.CmdIssuesReopen,
|
|
|
|
&issues.CmdIssuesClose,
|
2018-09-03 02:43:00 -04:00
|
|
|
},
|
2020-09-30 01:11:33 -04:00
|
|
|
Flags: flags.IssuePRFlags,
|
2018-09-03 02:43:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func runIssues(ctx *cli.Context) error {
|
2020-03-29 09:16:06 -04:00
|
|
|
if ctx.Args().Len() == 1 {
|
2020-12-15 12:38:22 -05:00
|
|
|
return runIssueDetail(ctx, ctx.Args().First())
|
2018-09-03 02:43:00 -04:00
|
|
|
}
|
2020-09-30 01:11:33 -04:00
|
|
|
return issues.RunIssuesList(ctx)
|
2018-09-03 02:43:00 -04:00
|
|
|
}
|
|
|
|
|
2020-12-15 12:38:22 -05:00
|
|
|
func runIssueDetail(cmd *cli.Context, index string) error {
|
|
|
|
ctx := context.InitCommand(cmd)
|
|
|
|
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
|
2018-09-03 02:43:00 -04:00
|
|
|
|
2020-09-30 01:11:33 -04:00
|
|
|
idx, err := utils.ArgToIndex(index)
|
2018-09-03 02:43:00 -04:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-12-15 12:38:22 -05:00
|
|
|
issue, _, err := ctx.Login.Client().GetIssue(ctx.Owner, ctx.Repo, idx)
|
2018-09-03 02:43:00 -04:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-09-30 01:11:33 -04:00
|
|
|
print.IssueDetails(issue)
|
2018-09-03 02:43:00 -04:00
|
|
|
return nil
|
|
|
|
}
|