mirror of
https://gitea.com/gitea/tea.git
synced 2025-09-02 18:08:30 +02:00
chore(cli): upgrade urfave/cli to v2 version (#85)
chore(cli): upgrade urfave/cli to v2 version Co-authored-by: Bo-Yi Wu <appleboy.tw@gmail.com> Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Reviewed-by: Andrew Thornton <art27@cantab.net>
This commit is contained in:

committed by
Andrew Thornton

parent
0a5cdd60ac
commit
c20d7d45aa
16
cmd/flags.go
16
cmd/flags.go
@ -7,7 +7,7 @@ package cmd
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/urfave/cli"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
// create global variables for global Flags to simplify
|
||||
@ -52,8 +52,8 @@ var OutputFlag = cli.StringFlag{
|
||||
// subcommand to work around issue and provide --login and --output:
|
||||
// https://github.com/urfave/cli/issues/585
|
||||
var LoginOutputFlags = []cli.Flag{
|
||||
LoginFlag,
|
||||
OutputFlag,
|
||||
&LoginFlag,
|
||||
&OutputFlag,
|
||||
}
|
||||
|
||||
// LoginRepoFlags defines login and repo flags that should
|
||||
@ -61,9 +61,9 @@ var LoginOutputFlags = []cli.Flag{
|
||||
// the subcommand to work around issue and provide --login and --repo:
|
||||
// https://github.com/urfave/cli/issues/585
|
||||
var LoginRepoFlags = []cli.Flag{
|
||||
LoginFlag,
|
||||
RepoFlag,
|
||||
RemoteFlag,
|
||||
&LoginFlag,
|
||||
&RepoFlag,
|
||||
&RemoteFlag,
|
||||
}
|
||||
|
||||
// AllDefaultFlags defines flags that should be available
|
||||
@ -71,8 +71,8 @@ var LoginRepoFlags = []cli.Flag{
|
||||
// to work around issue and provide --login, --repo and --output:
|
||||
// https://github.com/urfave/cli/issues/585
|
||||
var AllDefaultFlags = append([]cli.Flag{
|
||||
RepoFlag,
|
||||
RemoteFlag,
|
||||
&RepoFlag,
|
||||
&RemoteFlag,
|
||||
}, LoginOutputFlags...)
|
||||
|
||||
// initCommand returns repository and *Login based on flags
|
||||
|
@ -13,7 +13,7 @@ import (
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
|
||||
"github.com/urfave/cli"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
// CmdIssues represents to login a gitea server.
|
||||
@ -22,9 +22,9 @@ var CmdIssues = cli.Command{
|
||||
Usage: "List and create issues",
|
||||
Description: `List and create issues`,
|
||||
Action: runIssues,
|
||||
Subcommands: []cli.Command{
|
||||
CmdIssuesList,
|
||||
CmdIssuesCreate,
|
||||
Subcommands: []*cli.Command{
|
||||
&CmdIssuesList,
|
||||
&CmdIssuesCreate,
|
||||
},
|
||||
Flags: AllDefaultFlags,
|
||||
}
|
||||
@ -124,11 +124,11 @@ var CmdIssuesCreate = cli.Command{
|
||||
Description: `Create an issue on repository`,
|
||||
Action: runIssuesCreate,
|
||||
Flags: append([]cli.Flag{
|
||||
cli.StringFlag{
|
||||
&cli.StringFlag{
|
||||
Name: "title, t",
|
||||
Usage: "issue title to create",
|
||||
},
|
||||
cli.StringFlag{
|
||||
&cli.StringFlag{
|
||||
Name: "body, b",
|
||||
Usage: "issue body to create",
|
||||
},
|
||||
|
@ -14,7 +14,7 @@ import (
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
|
||||
"github.com/urfave/cli"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
// CmdLabels represents to operate repositories' labels.
|
||||
@ -23,13 +23,13 @@ var CmdLabels = cli.Command{
|
||||
Usage: "Manage issue labels",
|
||||
Description: `Manage issue labels`,
|
||||
Action: runLabels,
|
||||
Subcommands: []cli.Command{
|
||||
CmdLabelCreate,
|
||||
CmdLabelUpdate,
|
||||
CmdLabelDelete,
|
||||
Subcommands: []*cli.Command{
|
||||
&CmdLabelCreate,
|
||||
&CmdLabelUpdate,
|
||||
&CmdLabelDelete,
|
||||
},
|
||||
Flags: append([]cli.Flag{
|
||||
cli.StringFlag{
|
||||
&cli.StringFlag{
|
||||
Name: "save, s",
|
||||
Usage: "Save all the labels as a file",
|
||||
},
|
||||
@ -94,19 +94,19 @@ var CmdLabelCreate = cli.Command{
|
||||
Description: `Create a label`,
|
||||
Action: runLabelCreate,
|
||||
Flags: []cli.Flag{
|
||||
cli.StringFlag{
|
||||
&cli.StringFlag{
|
||||
Name: "name",
|
||||
Usage: "label name",
|
||||
},
|
||||
cli.StringFlag{
|
||||
&cli.StringFlag{
|
||||
Name: "color",
|
||||
Usage: "label color value",
|
||||
},
|
||||
cli.StringFlag{
|
||||
&cli.StringFlag{
|
||||
Name: "description",
|
||||
Usage: "label description",
|
||||
},
|
||||
cli.StringFlag{
|
||||
&cli.StringFlag{
|
||||
Name: "file",
|
||||
Usage: "indicate a label file",
|
||||
},
|
||||
@ -186,19 +186,19 @@ var CmdLabelUpdate = cli.Command{
|
||||
Description: `Update a label`,
|
||||
Action: runLabelUpdate,
|
||||
Flags: []cli.Flag{
|
||||
cli.IntFlag{
|
||||
&cli.IntFlag{
|
||||
Name: "id",
|
||||
Usage: "label id",
|
||||
},
|
||||
cli.StringFlag{
|
||||
&cli.StringFlag{
|
||||
Name: "name",
|
||||
Usage: "label name",
|
||||
},
|
||||
cli.StringFlag{
|
||||
&cli.StringFlag{
|
||||
Name: "color",
|
||||
Usage: "label color value",
|
||||
},
|
||||
cli.StringFlag{
|
||||
&cli.StringFlag{
|
||||
Name: "description",
|
||||
Usage: "label description",
|
||||
},
|
||||
@ -246,7 +246,7 @@ var CmdLabelDelete = cli.Command{
|
||||
Description: `Delete a label`,
|
||||
Action: runLabelCreate,
|
||||
Flags: []cli.Flag{
|
||||
cli.IntFlag{
|
||||
&cli.IntFlag{
|
||||
Name: "id",
|
||||
Usage: "label id",
|
||||
},
|
||||
|
32
cmd/login.go
32
cmd/login.go
@ -13,7 +13,7 @@ import (
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
|
||||
"github.com/urfave/cli"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
// CmdLogin represents to login a gitea server.
|
||||
@ -21,9 +21,9 @@ var CmdLogin = cli.Command{
|
||||
Name: "login",
|
||||
Usage: "Log in to a Gitea server",
|
||||
Description: `Log in to a Gitea server`,
|
||||
Subcommands: []cli.Command{
|
||||
cmdLoginList,
|
||||
cmdLoginAdd,
|
||||
Subcommands: []*cli.Command{
|
||||
&cmdLoginList,
|
||||
&cmdLoginAdd,
|
||||
},
|
||||
}
|
||||
|
||||
@ -33,23 +33,23 @@ var cmdLoginAdd = cli.Command{
|
||||
Usage: "Add a Gitea login",
|
||||
Description: `Add a Gitea login`,
|
||||
Flags: []cli.Flag{
|
||||
cli.StringFlag{
|
||||
&cli.StringFlag{
|
||||
Name: "name, n",
|
||||
Usage: "Login name",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "url, u",
|
||||
Value: "https://try.gitea.io",
|
||||
EnvVar: "GITEA_SERVER_URL",
|
||||
Usage: "Server URL",
|
||||
&cli.StringFlag{
|
||||
Name: "url, u",
|
||||
Value: "https://try.gitea.io",
|
||||
EnvVars: []string{"GITEA_SERVER_URL"},
|
||||
Usage: "Server URL",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "token, t",
|
||||
Value: "",
|
||||
EnvVar: "GITEA_SERVER_TOKEN",
|
||||
Usage: "Access token. Can be obtained from Settings > Applications",
|
||||
&cli.StringFlag{
|
||||
Name: "token, t",
|
||||
Value: "",
|
||||
EnvVars: []string{"GITEA_SERVER_TOKEN"},
|
||||
Usage: "Access token. Can be obtained from Settings > Applications",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
&cli.BoolFlag{
|
||||
Name: "insecure, i",
|
||||
Usage: "Disable TLS verification",
|
||||
},
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/urfave/cli"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
// CmdLogout represents to logout a gitea server.
|
||||
@ -19,7 +19,7 @@ var CmdLogout = cli.Command{
|
||||
Description: `Log out from a Gitea server`,
|
||||
Action: runLogout,
|
||||
Flags: []cli.Flag{
|
||||
cli.StringFlag{
|
||||
&cli.StringFlag{
|
||||
Name: "name, n",
|
||||
Usage: "Login name to remove",
|
||||
},
|
||||
|
@ -10,7 +10,7 @@ import (
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
|
||||
"github.com/urfave/cli"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
// CmdPulls represents to login a gitea server.
|
||||
|
@ -11,7 +11,7 @@ import (
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
|
||||
"github.com/urfave/cli"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
// CmdReleases represents to login a gitea server.
|
||||
@ -20,8 +20,8 @@ var CmdReleases = cli.Command{
|
||||
Usage: "Create releases",
|
||||
Description: `Create releases`,
|
||||
Action: runReleases,
|
||||
Subcommands: []cli.Command{
|
||||
CmdReleaseCreate,
|
||||
Subcommands: []*cli.Command{
|
||||
&CmdReleaseCreate,
|
||||
},
|
||||
Flags: AllDefaultFlags,
|
||||
}
|
||||
@ -71,31 +71,31 @@ var CmdReleaseCreate = cli.Command{
|
||||
Description: `Create a release`,
|
||||
Action: runReleaseCreate,
|
||||
Flags: append([]cli.Flag{
|
||||
cli.StringFlag{
|
||||
&cli.StringFlag{
|
||||
Name: "tag",
|
||||
Usage: "Tag name",
|
||||
},
|
||||
cli.StringFlag{
|
||||
&cli.StringFlag{
|
||||
Name: "target",
|
||||
Usage: "Target refs, branch name or commit id",
|
||||
},
|
||||
cli.StringFlag{
|
||||
&cli.StringFlag{
|
||||
Name: "title, t",
|
||||
Usage: "Release title",
|
||||
},
|
||||
cli.StringFlag{
|
||||
&cli.StringFlag{
|
||||
Name: "note, n",
|
||||
Usage: "Release notes",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
&cli.BoolFlag{
|
||||
Name: "draft, d",
|
||||
Usage: "Is a draft",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
&cli.BoolFlag{
|
||||
Name: "prerelease, p",
|
||||
Usage: "Is a pre-release",
|
||||
},
|
||||
cli.StringSliceFlag{
|
||||
&cli.StringSliceFlag{
|
||||
Name: "asset, a",
|
||||
Usage: "List of files to attach",
|
||||
},
|
||||
|
12
cmd/repos.go
12
cmd/repos.go
@ -9,7 +9,7 @@ import (
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
|
||||
"github.com/urfave/cli"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
// CmdRepos represents to login a gitea server.
|
||||
@ -18,8 +18,8 @@ var CmdRepos = cli.Command{
|
||||
Usage: "Operate with repositories",
|
||||
Description: `Operate with repositories`,
|
||||
Action: runReposList,
|
||||
Subcommands: []cli.Command{
|
||||
CmdReposList,
|
||||
Subcommands: []*cli.Command{
|
||||
&CmdReposList,
|
||||
},
|
||||
Flags: LoginOutputFlags,
|
||||
}
|
||||
@ -31,15 +31,15 @@ var CmdReposList = cli.Command{
|
||||
Description: `List available repositories`,
|
||||
Action: runReposList,
|
||||
Flags: append([]cli.Flag{
|
||||
cli.StringFlag{
|
||||
&cli.StringFlag{
|
||||
Name: "mode",
|
||||
Usage: "Filter listed repositories based on mode, optional - fork, mirror, source",
|
||||
},
|
||||
cli.StringFlag{
|
||||
&cli.StringFlag{
|
||||
Name: "org",
|
||||
Usage: "Filter listed repositories based on organization, optional",
|
||||
},
|
||||
cli.StringFlag{
|
||||
&cli.StringFlag{
|
||||
Name: "user",
|
||||
Usage: "Filter listed repositories absed on user, optional",
|
||||
},
|
||||
|
Reference in New Issue
Block a user