2018-09-03 08:43:00 +02: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 07:11:33 +02:00
|
|
|
"code.gitea.io/tea/cmd/flags"
|
|
|
|
"code.gitea.io/tea/cmd/issues"
|
|
|
|
"code.gitea.io/tea/modules/config"
|
|
|
|
"code.gitea.io/tea/modules/print"
|
|
|
|
"code.gitea.io/tea/modules/utils"
|
2018-09-03 08:43:00 +02:00
|
|
|
|
2020-01-04 18:44:25 +01:00
|
|
|
"github.com/urfave/cli/v2"
|
2018-09-03 08:43:00 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
// CmdIssues represents to login a gitea server.
|
|
|
|
var CmdIssues = cli.Command{
|
|
|
|
Name: "issues",
|
2020-09-27 16:35:53 +02:00
|
|
|
Usage: "List, create and update issues",
|
|
|
|
Description: "List, create and update issues",
|
2020-04-22 18:09:26 +02:00
|
|
|
ArgsUsage: "[<issue index>]",
|
2018-09-03 08:43:00 +02:00
|
|
|
Action: runIssues,
|
2020-01-04 18:44:25 +01:00
|
|
|
Subcommands: []*cli.Command{
|
2020-09-30 07:11:33 +02:00
|
|
|
&issues.CmdIssuesList,
|
|
|
|
&issues.CmdIssuesCreate,
|
|
|
|
&issues.CmdIssuesReopen,
|
|
|
|
&issues.CmdIssuesClose,
|
2018-09-03 08:43:00 +02:00
|
|
|
},
|
2020-09-30 07:11:33 +02:00
|
|
|
Flags: flags.IssuePRFlags,
|
2018-09-03 08:43:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func runIssues(ctx *cli.Context) error {
|
2020-03-29 15:16:06 +02:00
|
|
|
if ctx.Args().Len() == 1 {
|
2020-09-30 07:11:33 +02:00
|
|
|
return runIssueDetail(ctx.Args().First())
|
2018-09-03 08:43:00 +02:00
|
|
|
}
|
2020-09-30 07:11:33 +02:00
|
|
|
return issues.RunIssuesList(ctx)
|
2018-09-03 08:43:00 +02:00
|
|
|
}
|
|
|
|
|
2020-09-30 07:11:33 +02:00
|
|
|
func runIssueDetail(index string) error {
|
|
|
|
login, owner, repo := config.InitCommand(flags.GlobalRepoValue, flags.GlobalLoginValue, flags.GlobalRemoteValue)
|
2018-09-03 08:43:00 +02:00
|
|
|
|
2020-09-30 07:11:33 +02:00
|
|
|
idx, err := utils.ArgToIndex(index)
|
2018-09-03 08:43:00 +02:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-09-16 04:01:41 +02:00
|
|
|
issue, _, err := login.Client().GetIssue(owner, repo, idx)
|
2018-09-03 08:43:00 +02:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-09-30 07:11:33 +02:00
|
|
|
print.IssueDetails(issue)
|
2018-09-03 08:43:00 +02:00
|
|
|
return nil
|
|
|
|
}
|