Added help message if no arguments passed to mc alias set command (#3963)

This commit is contained in:
jinapurapu
2022-02-09 03:14:03 -08:00
committed by GitHub
parent 3a7a724753
commit 548dc0fd99
+5 -6
View File
@@ -61,10 +61,8 @@ var aliasSetCmd = cli.Command{
HideHelpCommand: true,
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
USAGE:
{{.HelpName}} ALIAS URL ACCESSKEY SECRETKEY
FLAGS:
{{range .VisibleFlags}}{{.}}
{{end}}
@@ -73,24 +71,20 @@ EXAMPLES:
{{.DisableHistory}}
{{.Prompt}} {{.HelpName}} myminio http://localhost:9000 minio minio123
{{.EnableHistory}}
2. Add MinIO service under "myminio" alias, to use dns style bucket lookup. For security reasons
turn off bash history momentarily.
{{.DisableHistory}}
{{.Prompt}} {{.HelpName}} myminio http://localhost:9000 minio minio123 --api "s3v4" --path "off"
{{.EnableHistory}}
3. Add Amazon S3 storage service under "mys3" alias. For security reasons turn off bash history momentarily.
{{.DisableHistory}}
{{.Prompt}} {{.HelpName}} mys3 https://s3.amazonaws.com \
BKIKJAA5BMMU2RHO6IBB V8f1CwQqAcwo80UEIJEjc5gVQUSSx5ohQ9GSrr12
{{.EnableHistory}}
4. Add Amazon S3 storage service under "mys3" alias, prompting for keys.
{{.Prompt}} {{.HelpName}} mys3 https://s3.amazonaws.com --api "s3v4" --path "off"
Enter Access Key: BKIKJAA5BMMU2RHO6IBB
Enter Secret Key: V8f1CwQqAcwo80UEIJEjc5gVQUSSx5ohQ9GSrr12
5. Add Amazon S3 storage service under "mys3" alias using piped keys.
{{.DisableHistory}}
{{.Prompt}} echo -e "BKIKJAA5BMMU2RHO6IBB\nV8f1CwQqAcwo80UEIJEjc5gVQUSSx5ohQ9GSrr12" | \
@@ -103,6 +97,11 @@ EXAMPLES:
func checkAliasSetSyntax(ctx *cli.Context, accessKey string, secretKey string, deprecated bool) {
args := ctx.Args()
argsNr := len(args)
if argsNr == 0 {
cli.ShowCommandHelpAndExit(ctx, ctx.Command.Name, 1) // last argument is exit code
}
if argsNr > 4 || argsNr < 2 {
fatalIf(errInvalidArgument().Trace(ctx.Args().Tail()...),
"Incorrect number of arguments for alias set command.")