Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrate urfave/cli to v2 version #10912

Closed
wants to merge 55 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
3be0b4d
convert to v2
6543 Mar 31, 2020
d8f28e1
make it work
6543 Apr 6, 2020
eb1ab6d
Merge branch 'master' into update-vendor-cli
6543 Apr 11, 2020
9282c08
Merge branch 'master' into update-vendor-cli
6543 Apr 15, 2020
8882aa4
Merge branch 'master' into update-vendor-cli
6543 Apr 18, 2020
eec0c63
Merge branch 'master' into update-vendor-cli
6543 Apr 20, 2020
0bb59fb
Merge branch 'master' into update-vendor-cli
6543 Apr 24, 2020
597b7cf
Merge branch 'master' into update-vendor-cli
6543 Apr 30, 2020
20a2852
Merge branch 'master' into update-vendor-cli
6543 May 7, 2020
fe9e08b
Merge branch 'master' into update-vendor-cli
6543 May 9, 2020
03fd71c
Merge branch 'master' into update-vendor-cli
6543 May 16, 2020
4cf3a81
update
6543 May 16, 2020
50008b8
handle Aliases correctly
6543 May 16, 2020
e81bc9b
fix lint
6543 May 16, 2020
622dc39
Merge branch 'master' into update-vendor-cli
6543 May 16, 2020
33f06e7
Merge branch 'master' into update-vendor-cli
6543 May 16, 2020
f06abde
Merge branch 'master' into update-vendor-cli
6543 May 17, 2020
5f90791
fix missing
6543 May 17, 2020
68da664
format
6543 May 17, 2020
ef49464
Merge branch 'master' into update-vendor-cli
6543 May 17, 2020
257ec71
Merge branch 'master' into update-vendor-cli
6543 May 23, 2020
76ece26
Merge branch 'master' into update-vendor-cli
6543 May 28, 2020
8802590
Merge branch 'master' into update-vendor-cli
techknowlogick Jun 16, 2020
14d090d
Merge branch 'master' into update-vendor-cli
6543 Jun 16, 2020
3e10435
update
6543 Jun 16, 2020
5092806
Merge branch 'master' into update-vendor-cli
6543 Jun 16, 2020
9ddd4f1
Merge branch 'master' into update-vendor-cli
6543 Jun 24, 2020
d8c8070
Merge branch 'master' into update-vendor-cli
6543 Aug 7, 2020
dcc721a
Merge branch 'master' into update-vendor-cli
6543 Nov 6, 2020
0131915
migrate
6543 Nov 6, 2020
9eed4e7
Update cmd/mailer.go
6543 Nov 6, 2020
7e8b7b8
Merge branch 'master' into update-vendor-cli
6543 Nov 6, 2020
6c51478
fix-vendor
6543 Nov 6, 2020
33aad45
upgrade cli to v2.3.0
6543 Nov 6, 2020
34c047d
Merge branch 'master' into update-vendor-cli
6543 Jan 26, 2021
ce80911
Cleanup & Fix
6543 Jan 26, 2021
925b7e3
fix2
6543 Jan 26, 2021
cc1d5c9
fix Alias
6543 Jan 26, 2021
661a807
make vendor
6543 Jan 26, 2021
fed4f54
log error more verbose
6543 Jan 26, 2021
6cbf152
Merge branch 'master' into update-vendor-cli
6543 Jan 26, 2021
5f40086
Merge branch 'master' into update-vendor-cli
6543 Jan 30, 2021
202a28e
fix merge-conflict relicts
6543 Jan 30, 2021
ddde054
Merge branch 'master' into update-vendor-cli
6543 Jun 18, 2021
47e6585
Merge branch 'master' into update-vendor-cli
6543 Jan 4, 2022
009ecc8
migrate new
6543 Jan 4, 2022
77ab411
NewExitError -> Exit
6543 Jan 4, 2022
f7799ea
Merge branch 'master' into update-vendor-cli
6543 Mar 2, 2022
e788598
update ...
6543 Mar 2, 2022
305a5e1
update
6543 Mar 2, 2022
6f49725
Merge branch 'master' into update-vendor-cli
6543 Mar 2, 2022
5045b05
fix lint
6543 Mar 2, 2022
43f2a05
Merge branch 'master' into update-vendor-cli
6543 May 13, 2022
9d2a5a6
cleanup merge conflicts
6543 May 13, 2022
9967cfd
adopt v2
6543 May 13, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
214 changes: 112 additions & 102 deletions cmd/admin.go

Large diffs are not rendered by default.

50 changes: 25 additions & 25 deletions cmd/admin_auth_ldap.go
Expand Up @@ -12,7 +12,7 @@ import (
"code.gitea.io/gitea/models/auth"
"code.gitea.io/gitea/services/auth/source/ldap"

"github.com/urfave/cli"
"github.com/urfave/cli/v2"
)

type (
Expand All @@ -26,104 +26,104 @@ type (

var (
commonLdapCLIFlags = []cli.Flag{
cli.StringFlag{
&cli.StringFlag{
Name: "name",
Usage: "Authentication name.",
},
cli.BoolFlag{
&cli.BoolFlag{
Name: "not-active",
Usage: "Deactivate the authentication source.",
},
cli.StringFlag{
&cli.StringFlag{
Name: "security-protocol",
Usage: "Security protocol name.",
},
cli.BoolFlag{
&cli.BoolFlag{
Name: "skip-tls-verify",
Usage: "Disable TLS verification.",
},
cli.StringFlag{
&cli.StringFlag{
Name: "host",
Usage: "The address where the LDAP server can be reached.",
},
cli.IntFlag{
&cli.IntFlag{
Name: "port",
Usage: "The port to use when connecting to the LDAP server.",
},
cli.StringFlag{
&cli.StringFlag{
Name: "user-search-base",
Usage: "The LDAP base at which user accounts will be searched for.",
},
cli.StringFlag{
&cli.StringFlag{
Name: "user-filter",
Usage: "An LDAP filter declaring how to find the user record that is attempting to authenticate.",
},
cli.StringFlag{
&cli.StringFlag{
Name: "admin-filter",
Usage: "An LDAP filter specifying if a user should be given administrator privileges.",
},
cli.StringFlag{
&cli.StringFlag{
Name: "restricted-filter",
Usage: "An LDAP filter specifying if a user should be given restricted status.",
},
cli.BoolFlag{
&cli.BoolFlag{
Name: "allow-deactivate-all",
Usage: "Allow empty search results to deactivate all users.",
},
cli.StringFlag{
&cli.StringFlag{
Name: "username-attribute",
Usage: "The attribute of the user’s LDAP record containing the user name.",
},
cli.StringFlag{
&cli.StringFlag{
Name: "firstname-attribute",
Usage: "The attribute of the user’s LDAP record containing the user’s first name.",
},
cli.StringFlag{
&cli.StringFlag{
Name: "surname-attribute",
Usage: "The attribute of the user’s LDAP record containing the user’s surname.",
},
cli.StringFlag{
&cli.StringFlag{
Name: "email-attribute",
Usage: "The attribute of the user’s LDAP record containing the user’s email address.",
},
cli.StringFlag{
&cli.StringFlag{
Name: "public-ssh-key-attribute",
Usage: "The attribute of the user’s LDAP record containing the user’s public ssh key.",
},
cli.BoolFlag{
&cli.BoolFlag{
Name: "skip-local-2fa",
Usage: "Set to true to skip local 2fa for users authenticated by this source",
},
cli.StringFlag{
&cli.StringFlag{
Name: "avatar-attribute",
Usage: "The attribute of the user’s LDAP record containing the user’s avatar.",
},
}

ldapBindDnCLIFlags = append(commonLdapCLIFlags,
cli.StringFlag{
&cli.StringFlag{
Name: "bind-dn",
Usage: "The DN to bind to the LDAP server with when searching for the user.",
},
cli.StringFlag{
&cli.StringFlag{
Name: "bind-password",
Usage: "The password for the Bind DN, if any.",
},
cli.BoolFlag{
&cli.BoolFlag{
Name: "attributes-in-bind",
Usage: "Fetch attributes in bind DN context.",
},
cli.BoolFlag{
&cli.BoolFlag{
Name: "synchronize-users",
Usage: "Enable user synchronization.",
},
cli.UintFlag{
&cli.UintFlag{
Name: "page-size",
Usage: "Search page size.",
})

ldapSimpleAuthCLIFlags = append(commonLdapCLIFlags,
cli.StringFlag{
&cli.StringFlag{
Name: "user-dn",
Usage: "The user’s DN.",
})
Expand Down
2 changes: 1 addition & 1 deletion cmd/admin_auth_ldap_test.go
Expand Up @@ -12,7 +12,7 @@ import (
"code.gitea.io/gitea/services/auth/source/ldap"

"github.com/stretchr/testify/assert"
"github.com/urfave/cli"
"github.com/urfave/cli/v2"
)

func TestAddLdapBindDn(t *testing.T) {
Expand Down
14 changes: 7 additions & 7 deletions cmd/cert.go
Expand Up @@ -21,7 +21,7 @@ import (
"strings"
"time"

"github.com/urfave/cli"
"github.com/urfave/cli/v2"
)

// CmdCert represents the available cert sub-command.
Expand All @@ -32,32 +32,32 @@ var CmdCert = cli.Command{
Outputs to 'cert.pem' and 'key.pem' and will overwrite existing files.`,
Action: runCert,
Flags: []cli.Flag{
cli.StringFlag{
&cli.StringFlag{
Name: "host",
Value: "",
Usage: "Comma-separated hostnames and IPs to generate a certificate for",
},
cli.StringFlag{
&cli.StringFlag{
Name: "ecdsa-curve",
Value: "",
Usage: "ECDSA curve to use to generate a key. Valid values are P224, P256, P384, P521",
},
cli.IntFlag{
&cli.IntFlag{
Name: "rsa-bits",
Value: 2048,
Usage: "Size of RSA key to generate. Ignored if --ecdsa-curve is set",
},
cli.StringFlag{
&cli.StringFlag{
Name: "start-date",
Value: "",
Usage: "Creation date formatted as Jan 1 15:04:05 2011",
},
cli.DurationFlag{
&cli.DurationFlag{
Name: "duration",
Value: 365 * 24 * time.Hour,
Usage: "Duration that certificate is valid for",
},
cli.BoolFlag{
&cli.BoolFlag{
Name: "ca",
Usage: "whether this cert should be its own Certificate Authority",
},
Expand Down
2 changes: 1 addition & 1 deletion cmd/cmd.go
Expand Up @@ -20,7 +20,7 @@ import (
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/util"

"github.com/urfave/cli"
"github.com/urfave/cli/v2"
)

// argsSet checks that all the required arguments are set. args is a list of
Expand Down
2 changes: 1 addition & 1 deletion cmd/convert.go
Expand Up @@ -11,7 +11,7 @@ import (
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"

"github.com/urfave/cli"
"github.com/urfave/cli/v2"
)

// CmdConvert represents the available convert sub-command.
Expand Down
19 changes: 4 additions & 15 deletions cmd/docs.go
Expand Up @@ -7,9 +7,8 @@ package cmd
import (
"fmt"
"os"
"strings"

"github.com/urfave/cli"
"github.com/urfave/cli/v2"
)

// CmdDocs represents the available docs sub-command.
Expand All @@ -24,8 +23,9 @@ var CmdDocs = cli.Command{
Usage: "Output man pages instead",
},
&cli.StringFlag{
Name: "output, o",
Usage: "Path to output to instead of stdout (will overwrite if exists)",
Name: "output",
Aliases: []string{"o"},
Usage: "Path to output to instead of stdout (will overwrite if exists)",
},
},
}
Expand All @@ -39,17 +39,6 @@ func runDocs(ctx *cli.Context) error {
return err
}

if !ctx.Bool("man") {
// Clean up markdown. The following bug was fixed in v2, but is present in v1.
// It affects markdown output (even though the issue is referring to man pages)
// https://github.com/urfave/cli/issues/1040
firstHashtagIndex := strings.Index(docs, "#")

if firstHashtagIndex > 0 {
docs = docs[firstHashtagIndex:]
}
}

out := os.Stdout
if ctx.String("output") != "" {
fi, err := os.Create(ctx.String("output"))
Expand Down
27 changes: 14 additions & 13 deletions cmd/doctor.go
Expand Up @@ -17,7 +17,7 @@ import (
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"

"github.com/urfave/cli"
"github.com/urfave/cli/v2"
"xorm.io/xorm"
)

Expand All @@ -28,37 +28,38 @@ var CmdDoctor = cli.Command{
Description: "A command to diagnose problems with the current Gitea instance according to the given configuration.",
Action: runDoctor,
Flags: []cli.Flag{
cli.BoolFlag{
&cli.BoolFlag{
Name: "list",
Usage: "List the available checks",
},
cli.BoolFlag{
&cli.BoolFlag{
Name: "default",
Usage: "Run the default checks (if neither --run or --all is set, this is the default behaviour)",
},
cli.StringSliceFlag{
&cli.StringSliceFlag{
Name: "run",
Usage: "Run the provided checks - (if --default is set, the default checks will also run)",
},
cli.BoolFlag{
&cli.BoolFlag{
Name: "all",
Usage: "Run all the available checks",
},
cli.BoolFlag{
&cli.BoolFlag{
Name: "fix",
Usage: "Automatically fix what we can",
},
cli.StringFlag{
&cli.StringFlag{
Name: "log-file",
Usage: `Name of the log file (default: "doctor.log"). Set to "-" to output to stdout, set to "" to disable`,
},
cli.BoolFlag{
Name: "color, H",
Usage: "Use color for outputted information",
&cli.BoolFlag{
Name: "color",
Aliases: []string{"H"},
Usage: "Use color for outputted information",
},
},
Subcommands: []cli.Command{
cmdRecreateTable,
Subcommands: []*cli.Command{
&cmdRecreateTable,
},
}

Expand All @@ -67,7 +68,7 @@ var cmdRecreateTable = cli.Command{
Usage: "Recreate tables from XORM definitions and copy the data.",
ArgsUsage: "[TABLE]... : (TABLEs to recreate - leave blank for all)",
Flags: []cli.Flag{
cli.BoolFlag{
&cli.BoolFlag{
Name: "debug",
Usage: "Print SQL commands sent",
},
Expand Down