mirror of
				https://gitea.com/gitea/tea.git
				synced 2025-10-31 01:05:26 +01:00 
			
		
		
		
	migrate tea to urfave v3 (#760)
I tested this somewhat, but I haven't been using the cli before so I'm not sure if there are changes - there shouldn't be though. Reviewed-on: https://gitea.com/gitea/tea/pulls/760 Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: TheFox0x7 <thefox0x7@gmail.com> Co-committed-by: TheFox0x7 <thefox0x7@gmail.com>
This commit is contained in:
		| @@ -7,13 +7,14 @@ import ( | ||||
| 	"fmt" | ||||
| 	"strings" | ||||
|  | ||||
| 	stdctx "context" | ||||
|  | ||||
| 	"code.gitea.io/sdk/gitea" | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
| 	"code.gitea.io/tea/modules/task" | ||||
| 	"code.gitea.io/tea/modules/utils" | ||||
|  | ||||
| 	"code.gitea.io/sdk/gitea" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| 	"github.com/urfave/cli/v3" | ||||
| ) | ||||
|  | ||||
| // CmdPullsApprove approves a PR | ||||
| @@ -23,7 +24,7 @@ var CmdPullsApprove = cli.Command{ | ||||
| 	Usage:       "Approve a pull request", | ||||
| 	Description: "Approve a pull request", | ||||
| 	ArgsUsage:   "<pull index> [<comment>]", | ||||
| 	Action: func(cmd *cli.Context) error { | ||||
| 	Action: func(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 		ctx := context.InitCommand(cmd) | ||||
| 		ctx.Ensure(context.CtxRequirement{RemoteRepo: true}) | ||||
|  | ||||
|   | ||||
| @@ -4,6 +4,7 @@ | ||||
| package pulls | ||||
|  | ||||
| import ( | ||||
| 	stdctx "context" | ||||
| 	"fmt" | ||||
|  | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| @@ -12,7 +13,7 @@ import ( | ||||
| 	"code.gitea.io/tea/modules/task" | ||||
| 	"code.gitea.io/tea/modules/utils" | ||||
|  | ||||
| 	"github.com/urfave/cli/v2" | ||||
| 	"github.com/urfave/cli/v3" | ||||
| ) | ||||
|  | ||||
| // CmdPullsCheckout is a command to locally checkout the given PR | ||||
| @@ -32,7 +33,7 @@ var CmdPullsCheckout = cli.Command{ | ||||
| 	}, flags.AllDefaultFlags...), | ||||
| } | ||||
|  | ||||
| func runPullsCheckout(cmd *cli.Context) error { | ||||
| func runPullsCheckout(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 	ctx := context.InitCommand(cmd) | ||||
| 	ctx.Ensure(context.CtxRequirement{ | ||||
| 		LocalRepo:  true, | ||||
|   | ||||
| @@ -6,13 +6,14 @@ package pulls | ||||
| import ( | ||||
| 	"fmt" | ||||
|  | ||||
| 	stdctx "context" | ||||
|  | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
| 	"code.gitea.io/tea/modules/interact" | ||||
| 	"code.gitea.io/tea/modules/task" | ||||
| 	"code.gitea.io/tea/modules/utils" | ||||
|  | ||||
| 	"github.com/urfave/cli/v2" | ||||
| 	"github.com/urfave/cli/v3" | ||||
| ) | ||||
|  | ||||
| // CmdPullsClean removes the remote and local feature branches, if a PR is merged. | ||||
| @@ -30,7 +31,7 @@ var CmdPullsClean = cli.Command{ | ||||
| 	}, flags.AllDefaultFlags...), | ||||
| } | ||||
|  | ||||
| func runPullsClean(cmd *cli.Context) error { | ||||
| func runPullsClean(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 	ctx := context.InitCommand(cmd) | ||||
| 	ctx.Ensure(context.CtxRequirement{LocalRepo: true}) | ||||
| 	if ctx.Args().Len() != 1 { | ||||
|   | ||||
| @@ -4,10 +4,12 @@ | ||||
| package pulls | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
|  | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
|  | ||||
| 	"code.gitea.io/sdk/gitea" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| 	"github.com/urfave/cli/v3" | ||||
| ) | ||||
|  | ||||
| // CmdPullsClose closes a given open pull request | ||||
| @@ -16,9 +18,9 @@ var CmdPullsClose = cli.Command{ | ||||
| 	Usage:       "Change state of one or more pull requests to 'closed'", | ||||
| 	Description: `Change state of one or more pull requests to 'closed'`, | ||||
| 	ArgsUsage:   "<pull index> [<pull index>...]", | ||||
| 	Action: func(ctx *cli.Context) error { | ||||
| 	Action: func(ctx context.Context, cmd *cli.Command) error { | ||||
| 		var s = gitea.StateClosed | ||||
| 		return editPullState(ctx, gitea.EditPullRequestOption{State: &s}) | ||||
| 		return editPullState(ctx, cmd, gitea.EditPullRequestOption{State: &s}) | ||||
| 	}, | ||||
| 	Flags: flags.AllDefaultFlags, | ||||
| } | ||||
|   | ||||
| @@ -4,12 +4,13 @@ | ||||
| package pulls | ||||
|  | ||||
| import ( | ||||
| 	stdctx "context" | ||||
|  | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
| 	"code.gitea.io/tea/modules/interact" | ||||
| 	"code.gitea.io/tea/modules/task" | ||||
|  | ||||
| 	"github.com/urfave/cli/v2" | ||||
| 	"github.com/urfave/cli/v3" | ||||
| ) | ||||
|  | ||||
| // CmdPullsCreate creates a pull request | ||||
| @@ -38,7 +39,7 @@ var CmdPullsCreate = cli.Command{ | ||||
| 	}, flags.IssuePRCreateFlags...), | ||||
| } | ||||
|  | ||||
| func runPullsCreate(cmd *cli.Context) error { | ||||
| func runPullsCreate(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 	ctx := context.InitCommand(cmd) | ||||
|  | ||||
| 	// no args -> interactive mode | ||||
|   | ||||
| @@ -4,6 +4,7 @@ | ||||
| package pulls | ||||
|  | ||||
| import ( | ||||
| 	stdctx "context" | ||||
| 	"fmt" | ||||
|  | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
| @@ -11,11 +12,11 @@ import ( | ||||
| 	"code.gitea.io/tea/modules/utils" | ||||
|  | ||||
| 	"code.gitea.io/sdk/gitea" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| 	"github.com/urfave/cli/v3" | ||||
| ) | ||||
|  | ||||
| // editPullState abstracts the arg parsing to edit the given pull request | ||||
| func editPullState(cmd *cli.Context, opts gitea.EditPullRequestOption) error { | ||||
| func editPullState(_ stdctx.Context, cmd *cli.Command, opts gitea.EditPullRequestOption) error { | ||||
| 	ctx := context.InitCommand(cmd) | ||||
| 	ctx.Ensure(context.CtxRequirement{RemoteRepo: true}) | ||||
| 	if ctx.Args().Len() == 0 { | ||||
|   | ||||
| @@ -4,12 +4,13 @@ | ||||
| package pulls | ||||
|  | ||||
| import ( | ||||
| 	stdctx "context" | ||||
|  | ||||
| 	"code.gitea.io/sdk/gitea" | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
| 	"code.gitea.io/tea/modules/print" | ||||
|  | ||||
| 	"code.gitea.io/sdk/gitea" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| 	"github.com/urfave/cli/v3" | ||||
| ) | ||||
|  | ||||
| var pullFieldsFlag = flags.FieldsFlag(print.PullFields, []string{ | ||||
| @@ -28,7 +29,7 @@ var CmdPullsList = cli.Command{ | ||||
| } | ||||
|  | ||||
| // RunPullsList return list of pulls | ||||
| func RunPullsList(cmd *cli.Context) error { | ||||
| func RunPullsList(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 	ctx := context.InitCommand(cmd) | ||||
| 	ctx.Ensure(context.CtxRequirement{RemoteRepo: true}) | ||||
|  | ||||
|   | ||||
| @@ -4,14 +4,15 @@ | ||||
| package pulls | ||||
|  | ||||
| import ( | ||||
| 	stdctx "context" | ||||
|  | ||||
| 	"code.gitea.io/sdk/gitea" | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
| 	"code.gitea.io/tea/modules/interact" | ||||
| 	"code.gitea.io/tea/modules/task" | ||||
| 	"code.gitea.io/tea/modules/utils" | ||||
|  | ||||
| 	"github.com/urfave/cli/v2" | ||||
| 	"github.com/urfave/cli/v3" | ||||
| ) | ||||
|  | ||||
| // CmdPullsMerge merges a PR | ||||
| @@ -39,7 +40,7 @@ var CmdPullsMerge = cli.Command{ | ||||
| 			Usage:   "Merge commit message", | ||||
| 		}, | ||||
| 	}, flags.AllDefaultFlags...), | ||||
| 	Action: func(cmd *cli.Context) error { | ||||
| 	Action: func(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 		ctx := context.InitCommand(cmd) | ||||
| 		ctx.Ensure(context.CtxRequirement{RemoteRepo: true}) | ||||
|  | ||||
|   | ||||
| @@ -4,6 +4,7 @@ | ||||
| package pulls | ||||
|  | ||||
| import ( | ||||
| 	stdctx "context" | ||||
| 	"fmt" | ||||
| 	"strings" | ||||
|  | ||||
| @@ -13,7 +14,7 @@ import ( | ||||
| 	"code.gitea.io/tea/modules/utils" | ||||
|  | ||||
| 	"code.gitea.io/sdk/gitea" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| 	"github.com/urfave/cli/v3" | ||||
| ) | ||||
|  | ||||
| // CmdPullsReject requests changes to a PR | ||||
| @@ -22,7 +23,7 @@ var CmdPullsReject = cli.Command{ | ||||
| 	Usage:       "Request changes to a pull request", | ||||
| 	Description: "Request changes to a pull request", | ||||
| 	ArgsUsage:   "<pull index> <reason>", | ||||
| 	Action: func(cmd *cli.Context) error { | ||||
| 	Action: func(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 		ctx := context.InitCommand(cmd) | ||||
| 		ctx.Ensure(context.CtxRequirement{RemoteRepo: true}) | ||||
|  | ||||
|   | ||||
| @@ -4,10 +4,12 @@ | ||||
| package pulls | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
|  | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
|  | ||||
| 	"code.gitea.io/sdk/gitea" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| 	"github.com/urfave/cli/v3" | ||||
| ) | ||||
|  | ||||
| // CmdPullsReopen reopens a given closed pull request | ||||
| @@ -17,9 +19,9 @@ var CmdPullsReopen = cli.Command{ | ||||
| 	Usage:       "Change state of one or more pull requests to 'open'", | ||||
| 	Description: `Change state of one or more pull requests to 'open'`, | ||||
| 	ArgsUsage:   "<pull index> [<pull index>...]", | ||||
| 	Action: func(ctx *cli.Context) error { | ||||
| 	Action: func(ctx context.Context, cmd *cli.Command) error { | ||||
| 		var s = gitea.StateOpen | ||||
| 		return editPullState(ctx, gitea.EditPullRequestOption{State: &s}) | ||||
| 		return editPullState(ctx, cmd, gitea.EditPullRequestOption{State: &s}) | ||||
| 	}, | ||||
| 	Flags: flags.AllDefaultFlags, | ||||
| } | ||||
|   | ||||
| @@ -4,6 +4,7 @@ | ||||
| package pulls | ||||
|  | ||||
| import ( | ||||
| 	stdctx "context" | ||||
| 	"fmt" | ||||
|  | ||||
| 	"code.gitea.io/tea/cmd/flags" | ||||
| @@ -11,7 +12,7 @@ import ( | ||||
| 	"code.gitea.io/tea/modules/interact" | ||||
| 	"code.gitea.io/tea/modules/utils" | ||||
|  | ||||
| 	"github.com/urfave/cli/v2" | ||||
| 	"github.com/urfave/cli/v3" | ||||
| ) | ||||
|  | ||||
| // CmdPullsReview starts an interactive review session | ||||
| @@ -20,7 +21,7 @@ var CmdPullsReview = cli.Command{ | ||||
| 	Usage:       "Interactively review a pull request", | ||||
| 	Description: "Interactively review a pull request", | ||||
| 	ArgsUsage:   "<pull index>", | ||||
| 	Action: func(cmd *cli.Context) error { | ||||
| 	Action: func(_ stdctx.Context, cmd *cli.Command) error { | ||||
| 		ctx := context.InitCommand(cmd) | ||||
| 		ctx.Ensure(context.CtxRequirement{RemoteRepo: true}) | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 TheFox0x7
					TheFox0x7