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