2020-09-30 13:11:33 +08:00
|
|
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
2023-09-08 09:40:02 +08:00
|
|
|
// SPDX-License-Identifier: MIT
|
2020-09-30 13:11:33 +08:00
|
|
|
|
|
|
|
package issues
|
|
|
|
|
|
|
|
import (
|
|
|
|
"code.gitea.io/tea/cmd/flags"
|
2020-12-16 01:38:22 +08:00
|
|
|
"code.gitea.io/tea/modules/context"
|
2020-12-15 04:05:31 +08:00
|
|
|
"code.gitea.io/tea/modules/interact"
|
|
|
|
"code.gitea.io/tea/modules/task"
|
2020-09-30 13:11:33 +08:00
|
|
|
|
|
|
|
"github.com/urfave/cli/v2"
|
|
|
|
)
|
|
|
|
|
|
|
|
// CmdIssuesCreate represents a sub command of issues to create issue
|
|
|
|
var CmdIssuesCreate = cli.Command{
|
|
|
|
Name: "create",
|
2020-12-17 00:47:40 +08:00
|
|
|
Aliases: []string{"c"},
|
2020-09-30 13:11:33 +08:00
|
|
|
Usage: "Create an issue on repository",
|
|
|
|
Description: `Create an issue on repository`,
|
2022-09-14 02:14:02 +08:00
|
|
|
ArgsUsage: " ", // command does not accept arguments
|
2020-09-30 13:11:33 +08:00
|
|
|
Action: runIssuesCreate,
|
2022-10-25 08:40:00 +08:00
|
|
|
Flags: flags.IssuePRCreateFlags,
|
2020-09-30 13:11:33 +08:00
|
|
|
}
|
|
|
|
|
2020-12-16 01:38:22 +08:00
|
|
|
func runIssuesCreate(cmd *cli.Context) error {
|
|
|
|
ctx := context.InitCommand(cmd)
|
|
|
|
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
|
2020-09-30 13:11:33 +08:00
|
|
|
|
2020-12-15 04:05:31 +08:00
|
|
|
if ctx.NumFlags() == 0 {
|
2020-12-16 01:38:22 +08:00
|
|
|
return interact.CreateIssue(ctx.Login, ctx.Owner, ctx.Repo)
|
2020-09-30 13:11:33 +08:00
|
|
|
}
|
|
|
|
|
2022-10-25 08:40:00 +08:00
|
|
|
opts, err := flags.GetIssuePRCreateFlags(ctx)
|
2021-03-08 19:48:03 +08:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2020-12-15 04:05:31 +08:00
|
|
|
return task.CreateIssue(
|
2020-12-16 01:38:22 +08:00
|
|
|
ctx.Login,
|
|
|
|
ctx.Owner,
|
|
|
|
ctx.Repo,
|
2021-03-08 19:48:03 +08:00
|
|
|
*opts,
|
2020-12-15 04:05:31 +08:00
|
|
|
)
|
2020-09-30 13:11:33 +08:00
|
|
|
}
|