2020-09-30 01:11:33 -04:00
|
|
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
2023-09-07 21:40:02 -04:00
|
|
|
// SPDX-License-Identifier: MIT
|
2020-09-30 01:11:33 -04:00
|
|
|
|
|
|
|
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`,
|
2022-09-13 14:14:02 -04:00
|
|
|
ArgsUsage: " ", // command does not accept arguments
|
2020-09-30 01:11:33 -04:00
|
|
|
Action: runIssuesCreate,
|
2022-10-24 20:40:00 -04:00
|
|
|
Flags: flags.IssuePRCreateFlags,
|
2020-09-30 01:11:33 -04:00
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2022-10-24 20:40:00 -04:00
|
|
|
opts, err := flags.GetIssuePRCreateFlags(ctx)
|
2021-03-08 06:48:03 -05:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
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,
|
2021-03-08 06:48:03 -05:00
|
|
|
*opts,
|
2020-12-14 15:05:31 -05:00
|
|
|
)
|
2020-09-30 01:11:33 -04:00
|
|
|
}
|