2020-09-30 07:11:33 +02: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 18:38:22 +01:00
|
|
|
"code.gitea.io/tea/modules/context"
|
2020-12-14 21:05:31 +01:00
|
|
|
"code.gitea.io/tea/modules/interact"
|
|
|
|
"code.gitea.io/tea/modules/task"
|
2020-09-30 07:11:33 +02: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 17:47:40 +01:00
|
|
|
Aliases: []string{"c"},
|
2020-09-30 07:11:33 +02:00
|
|
|
Usage: "Create an issue on repository",
|
|
|
|
Description: `Create an issue on repository`,
|
|
|
|
Action: runIssuesCreate,
|
2021-03-08 12:48:03 +01:00
|
|
|
Flags: flags.IssuePREditFlags,
|
2020-09-30 07:11:33 +02:00
|
|
|
}
|
|
|
|
|
2020-12-15 18:38:22 +01:00
|
|
|
func runIssuesCreate(cmd *cli.Context) error {
|
|
|
|
ctx := context.InitCommand(cmd)
|
|
|
|
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
|
2020-09-30 07:11:33 +02:00
|
|
|
|
2020-12-14 21:05:31 +01:00
|
|
|
if ctx.NumFlags() == 0 {
|
2020-12-15 18:38:22 +01:00
|
|
|
return interact.CreateIssue(ctx.Login, ctx.Owner, ctx.Repo)
|
2020-09-30 07:11:33 +02:00
|
|
|
}
|
|
|
|
|
2021-03-08 12:48:03 +01:00
|
|
|
opts, err := flags.GetIssuePREditFlags(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2020-12-14 21:05:31 +01:00
|
|
|
return task.CreateIssue(
|
2020-12-15 18:38:22 +01:00
|
|
|
ctx.Login,
|
|
|
|
ctx.Owner,
|
|
|
|
ctx.Repo,
|
2021-03-08 12:48:03 +01:00
|
|
|
*opts,
|
2020-12-14 21:05:31 +01:00
|
|
|
)
|
2020-09-30 07:11:33 +02:00
|
|
|
}
|