2020-09-30 01:11:33 -04:00
|
|
|
// Copyright 2020 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 issues
|
|
|
|
|
|
|
|
import (
|
|
|
|
"code.gitea.io/tea/cmd/flags"
|
2020-12-15 12:38:22 -05:00
|
|
|
"code.gitea.io/tea/modules/context"
|
2020-12-14 15:05:31 -05:00
|
|
|
"code.gitea.io/tea/modules/interact"
|
|
|
|
"code.gitea.io/tea/modules/task"
|
2020-09-30 01:11:33 -04:00
|
|
|
|
|
|
|
"github.com/urfave/cli/v2"
|
|
|
|
)
|
|
|
|
|
|
|
|
// CmdIssuesCreate represents a sub command of issues to create issue
|
|
|
|
var CmdIssuesCreate = cli.Command{
|
|
|
|
Name: "create",
|
2020-12-16 11:47:40 -05:00
|
|
|
Aliases: []string{"c"},
|
2020-09-30 01:11:33 -04:00
|
|
|
Usage: "Create an issue on repository",
|
|
|
|
Description: `Create an issue on repository`,
|
|
|
|
Action: runIssuesCreate,
|
|
|
|
Flags: append([]cli.Flag{
|
|
|
|
&cli.StringFlag{
|
|
|
|
Name: "title",
|
|
|
|
Aliases: []string{"t"},
|
|
|
|
Usage: "issue title to create",
|
|
|
|
},
|
|
|
|
&cli.StringFlag{
|
|
|
|
Name: "body",
|
|
|
|
Aliases: []string{"b"},
|
|
|
|
Usage: "issue body to create",
|
|
|
|
},
|
|
|
|
}, flags.LoginRepoFlags...),
|
|
|
|
}
|
|
|
|
|
2020-12-15 12:38:22 -05:00
|
|
|
func runIssuesCreate(cmd *cli.Context) error {
|
|
|
|
ctx := context.InitCommand(cmd)
|
|
|
|
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
|
2020-09-30 01:11:33 -04:00
|
|
|
|
2020-12-14 15:05:31 -05:00
|
|
|
if ctx.NumFlags() == 0 {
|
2020-12-15 12:38:22 -05:00
|
|
|
return interact.CreateIssue(ctx.Login, ctx.Owner, ctx.Repo)
|
2020-09-30 01:11:33 -04:00
|
|
|
}
|
|
|
|
|
2020-12-14 15:05:31 -05:00
|
|
|
return task.CreateIssue(
|
2020-12-15 12:38:22 -05:00
|
|
|
ctx.Login,
|
|
|
|
ctx.Owner,
|
|
|
|
ctx.Repo,
|
2020-12-14 15:05:31 -05:00
|
|
|
ctx.String("title"),
|
|
|
|
ctx.String("body"),
|
|
|
|
)
|
2020-09-30 01:11:33 -04:00
|
|
|
}
|