mirror of
https://gitea.com/gitea/tea.git
synced 2024-12-18 07:05:11 +01:00
2a8c1daa67
fixes #229 fixes #502 interactive mode will be in a follow up Co-authored-by: Norwin <git@nroo.de> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://gitea.com/gitea/tea/pulls/506 Reviewed-by: 6543 <6543@obermui.de> Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: Norwin <noerw@noreply.gitea.io> Co-committed-by: Norwin <noerw@noreply.gitea.io>
64 lines
1.4 KiB
Go
64 lines
1.4 KiB
Go
// Copyright 2022 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 (
|
|
"fmt"
|
|
|
|
"code.gitea.io/tea/cmd/flags"
|
|
"code.gitea.io/tea/modules/context"
|
|
"code.gitea.io/tea/modules/print"
|
|
"code.gitea.io/tea/modules/task"
|
|
"code.gitea.io/tea/modules/utils"
|
|
|
|
"github.com/urfave/cli/v2"
|
|
)
|
|
|
|
// CmdIssuesEdit is the subcommand of issues to edit issues
|
|
var CmdIssuesEdit = cli.Command{
|
|
Name: "edit",
|
|
Aliases: []string{"e"},
|
|
Usage: "Edit one or more issues",
|
|
Description: `Edit one or more issues. To unset a property again,
|
|
use an empty string (eg. --milestone "").`,
|
|
ArgsUsage: "<idx> [<idx>...]",
|
|
Action: runIssuesEdit,
|
|
Flags: flags.IssuePREditFlags,
|
|
}
|
|
|
|
func runIssuesEdit(cmd *cli.Context) error {
|
|
ctx := context.InitCommand(cmd)
|
|
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
|
|
|
|
if !cmd.Args().Present() {
|
|
return fmt.Errorf("must specify at least one issue index")
|
|
}
|
|
|
|
opts, err := flags.GetIssuePREditFlags(ctx)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
indices, err := utils.ArgsToIndices(ctx.Args().Slice())
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
client := ctx.Login.Client()
|
|
for _, opts.Index = range indices {
|
|
issue, err := task.EditIssue(ctx, client, *opts)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if ctx.Args().Len() > 1 {
|
|
fmt.Println(issue.HTMLURL)
|
|
} else {
|
|
print.IssueDetails(issue, nil)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|