From 64b9e4cd166fd3ddcf6b8ed1b3ce43f6be45f1a4 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 26 Aug 2024 13:55:28 +0200 Subject: [PATCH] cli: rename args that collided with builtins (predeclard) cli/required.go:33:22: param min has same name as predeclared identifier (predeclared) func RequiresMinArgs(min int) cobra.PositionalArgs { ^ cli/required.go:50:22: param max has same name as predeclared identifier (predeclared) func RequiresMaxArgs(max int) cobra.PositionalArgs { ^ cli/required.go:67:24: param min has same name as predeclared identifier (predeclared) func RequiresRangeArgs(min int, max int) cobra.PositionalArgs { ^ Signed-off-by: Sebastiaan van Stijn (cherry picked from commit c4a55df7c040a4490c10f1aa5f4cfcef7dccfc1d) Signed-off-by: Sebastiaan van Stijn --- cli/required.go | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/cli/required.go b/cli/required.go index 454e247613..bad1624856 100644 --- a/cli/required.go +++ b/cli/required.go @@ -27,16 +27,16 @@ func NoArgs(cmd *cobra.Command, args []string) error { } // RequiresMinArgs returns an error if there is not at least min args -func RequiresMinArgs(min int) cobra.PositionalArgs { +func RequiresMinArgs(minArgs int) cobra.PositionalArgs { return func(cmd *cobra.Command, args []string) error { - if len(args) >= min { + if len(args) >= minArgs { return nil } return errors.Errorf( "%q requires at least %d %s.\nSee '%s --help'.\n\nUsage: %s\n\n%s", cmd.CommandPath(), - min, - pluralize("argument", min), + minArgs, + pluralize("argument", minArgs), cmd.CommandPath(), cmd.UseLine(), cmd.Short, @@ -45,16 +45,16 @@ func RequiresMinArgs(min int) cobra.PositionalArgs { } // RequiresMaxArgs returns an error if there is not at most max args -func RequiresMaxArgs(max int) cobra.PositionalArgs { +func RequiresMaxArgs(maxArgs int) cobra.PositionalArgs { return func(cmd *cobra.Command, args []string) error { - if len(args) <= max { + if len(args) <= maxArgs { return nil } return errors.Errorf( "%q requires at most %d %s.\nSee '%s --help'.\n\nUsage: %s\n\n%s", cmd.CommandPath(), - max, - pluralize("argument", max), + maxArgs, + pluralize("argument", maxArgs), cmd.CommandPath(), cmd.UseLine(), cmd.Short, @@ -63,17 +63,17 @@ func RequiresMaxArgs(max int) cobra.PositionalArgs { } // RequiresRangeArgs returns an error if there is not at least min args and at most max args -func RequiresRangeArgs(min int, max int) cobra.PositionalArgs { +func RequiresRangeArgs(minArgs int, maxArgs int) cobra.PositionalArgs { return func(cmd *cobra.Command, args []string) error { - if len(args) >= min && len(args) <= max { + if len(args) >= minArgs && len(args) <= maxArgs { return nil } return errors.Errorf( "%q requires at least %d and at most %d %s.\nSee '%s --help'.\n\nUsage: %s\n\n%s", cmd.CommandPath(), - min, - max, - pluralize("argument", max), + minArgs, + maxArgs, + pluralize("argument", maxArgs), cmd.CommandPath(), cmd.UseLine(), cmd.Short,