gitea-tea/cmd/issues.go

55 lines
1.3 KiB
Go
Raw Permalink Normal View History

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 (
"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
"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",
Aliases: []string{"issue"},
Usage: "List, create and update issues",
Description: "List, create and update issues",
ArgsUsage: "[<issue index>]",
2018-09-03 08:43:00 +02:00
Action: runIssues,
Subcommands: []*cli.Command{
&issues.CmdIssuesList,
&issues.CmdIssuesCreate,
&issues.CmdIssuesReopen,
&issues.CmdIssuesClose,
2018-09-03 08:43:00 +02:00
},
Flags: flags.IssuePRFlags,
2018-09-03 08:43:00 +02:00
}
func runIssues(ctx *cli.Context) error {
if ctx.Args().Len() == 1 {
return runIssueDetail(ctx.Args().First())
2018-09-03 08:43:00 +02:00
}
return issues.RunIssuesList(ctx)
2018-09-03 08:43:00 +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
idx, err := utils.ArgToIndex(index)
2018-09-03 08:43:00 +02:00
if err != nil {
return err
}
issue, _, err := login.Client().GetIssue(owner, repo, idx)
2018-09-03 08:43:00 +02:00
if err != nil {
return err
}
print.IssueDetails(issue)
2018-09-03 08:43:00 +02:00
return nil
}