diff --git a/cli/command/checkpoint/create_test.go b/cli/command/checkpoint/create_test.go index 3ad7922df6..b3b7372080 100644 --- a/cli/command/checkpoint/create_test.go +++ b/cli/command/checkpoint/create_test.go @@ -20,11 +20,11 @@ func TestCheckpointCreateErrors(t *testing.T) { }{ { args: []string{"too-few-arguments"}, - expectedError: "requires exactly 2 arguments", + expectedError: "requires 2 arguments", }, { args: []string{"too", "many", "arguments"}, - expectedError: "requires exactly 2 arguments", + expectedError: "requires 2 arguments", }, { args: []string{"foo", "bar"}, diff --git a/cli/command/checkpoint/list_test.go b/cli/command/checkpoint/list_test.go index 7ac4a768de..437cc1b359 100644 --- a/cli/command/checkpoint/list_test.go +++ b/cli/command/checkpoint/list_test.go @@ -20,11 +20,11 @@ func TestCheckpointListErrors(t *testing.T) { }{ { args: []string{}, - expectedError: "requires exactly 1 argument", + expectedError: "requires 1 argument", }, { args: []string{"too", "many", "arguments"}, - expectedError: "requires exactly 1 argument", + expectedError: "requires 1 argument", }, { args: []string{"foo"}, diff --git a/cli/command/checkpoint/remove_test.go b/cli/command/checkpoint/remove_test.go index 01bda3c04d..ae8402edb2 100644 --- a/cli/command/checkpoint/remove_test.go +++ b/cli/command/checkpoint/remove_test.go @@ -19,11 +19,11 @@ func TestCheckpointRemoveErrors(t *testing.T) { }{ { args: []string{"too-few-arguments"}, - expectedError: "requires exactly 2 arguments", + expectedError: "requires 2 arguments", }, { args: []string{"too", "many", "arguments"}, - expectedError: "requires exactly 2 arguments", + expectedError: "requires 2 arguments", }, { args: []string{"foo", "bar"}, diff --git a/cli/command/config/create_test.go b/cli/command/config/create_test.go index db9f8eac82..848f9c6e07 100644 --- a/cli/command/config/create_test.go +++ b/cli/command/config/create_test.go @@ -28,11 +28,11 @@ func TestConfigCreateErrors(t *testing.T) { }{ { args: []string{"too_few"}, - expectedError: "requires exactly 2 arguments", + expectedError: "requires 2 arguments", }, { args: []string{"too", "many", "arguments"}, - expectedError: "requires exactly 2 arguments", + expectedError: "requires 2 arguments", }, { args: []string{"name", filepath.Join("testdata", configDataFile)}, diff --git a/cli/command/config/remove_test.go b/cli/command/config/remove_test.go index 1466391ee5..d1c5a71f9f 100644 --- a/cli/command/config/remove_test.go +++ b/cli/command/config/remove_test.go @@ -19,7 +19,7 @@ func TestConfigRemoveErrors(t *testing.T) { }{ { args: []string{}, - expectedError: "requires at least 1 argument.", + expectedError: "requires at least 1 argument", }, { args: []string{"foo"}, diff --git a/cli/command/image/history_test.go b/cli/command/image/history_test.go index 86eeaba3ba..072bd035a6 100644 --- a/cli/command/image/history_test.go +++ b/cli/command/image/history_test.go @@ -23,7 +23,7 @@ func TestNewHistoryCommandErrors(t *testing.T) { { name: "wrong-args", args: []string{}, - expectedError: "requires exactly 1 argument.", + expectedError: "requires 1 argument", }, { name: "client-error", diff --git a/cli/command/image/import_test.go b/cli/command/image/import_test.go index 59a6ced04d..196171ed31 100644 --- a/cli/command/image/import_test.go +++ b/cli/command/image/import_test.go @@ -22,7 +22,7 @@ func TestNewImportCommandErrors(t *testing.T) { { name: "wrong-args", args: []string{}, - expectedError: "requires at least 1 argument.", + expectedError: "requires at least 1 argument", }, { name: "import-failed", diff --git a/cli/command/image/inspect_test.go b/cli/command/image/inspect_test.go index 61ea36012e..9e2163db57 100644 --- a/cli/command/image/inspect_test.go +++ b/cli/command/image/inspect_test.go @@ -21,7 +21,7 @@ func TestNewInspectCommandErrors(t *testing.T) { { name: "wrong-args", args: []string{}, - expectedError: "requires at least 1 argument.", + expectedError: "requires at least 1 argument", }, } for _, tc := range testCases { diff --git a/cli/command/image/list_test.go b/cli/command/image/list_test.go index 4917c53939..8ccec6ab56 100644 --- a/cli/command/image/list_test.go +++ b/cli/command/image/list_test.go @@ -24,7 +24,7 @@ func TestNewImagesCommandErrors(t *testing.T) { { name: "wrong-args", args: []string{"arg1", "arg2"}, - expectedError: "requires at most 1 argument.", + expectedError: "requires at most 1 argument", }, { name: "failed-list", diff --git a/cli/command/image/load_test.go b/cli/command/image/load_test.go index 9c36ce3235..5a8a499bda 100644 --- a/cli/command/image/load_test.go +++ b/cli/command/image/load_test.go @@ -24,7 +24,7 @@ func TestNewLoadCommandErrors(t *testing.T) { { name: "wrong-args", args: []string{"arg"}, - expectedError: "accepts no arguments.", + expectedError: "accepts no arguments", }, { name: "input-to-terminal", diff --git a/cli/command/image/prune_test.go b/cli/command/image/prune_test.go index 1d6b2de983..710c1cf748 100644 --- a/cli/command/image/prune_test.go +++ b/cli/command/image/prune_test.go @@ -27,7 +27,7 @@ func TestNewPruneCommandErrors(t *testing.T) { { name: "wrong-args", args: []string{"something"}, - expectedError: "accepts no arguments.", + expectedError: "accepts no arguments", }, { name: "prune-error", diff --git a/cli/command/image/pull_test.go b/cli/command/image/pull_test.go index 43bc772ea7..a28aaf6166 100644 --- a/cli/command/image/pull_test.go +++ b/cli/command/image/pull_test.go @@ -23,7 +23,7 @@ func TestNewPullCommandErrors(t *testing.T) { }{ { name: "wrong-args", - expectedError: "requires exactly 1 argument.", + expectedError: "requires 1 argument", args: []string{}, }, { diff --git a/cli/command/image/push_test.go b/cli/command/image/push_test.go index a659c6c510..3f9d2fe59f 100644 --- a/cli/command/image/push_test.go +++ b/cli/command/image/push_test.go @@ -21,7 +21,7 @@ func TestNewPushCommandErrors(t *testing.T) { { name: "wrong-args", args: []string{}, - expectedError: "requires exactly 1 argument.", + expectedError: "requires 1 argument", }, { name: "invalid-name", diff --git a/cli/command/image/remove_test.go b/cli/command/image/remove_test.go index d4340b3819..0340a65b94 100644 --- a/cli/command/image/remove_test.go +++ b/cli/command/image/remove_test.go @@ -39,7 +39,7 @@ func TestNewRemoveCommandErrors(t *testing.T) { }{ { name: "wrong args", - expectedError: "requires at least 1 argument.", + expectedError: "requires at least 1 argument", }, { name: "ImageRemove fail with force option", diff --git a/cli/command/image/save_test.go b/cli/command/image/save_test.go index c6cff4cc3c..dc64ebae93 100644 --- a/cli/command/image/save_test.go +++ b/cli/command/image/save_test.go @@ -23,7 +23,7 @@ func TestNewSaveCommandErrors(t *testing.T) { { name: "wrong args", args: []string{}, - expectedError: "requires at least 1 argument.", + expectedError: "requires at least 1 argument", }, { name: "output to terminal", diff --git a/cli/command/image/tag_test.go b/cli/command/image/tag_test.go index 77bf81c2db..65ceb60323 100644 --- a/cli/command/image/tag_test.go +++ b/cli/command/image/tag_test.go @@ -15,7 +15,7 @@ func TestCliNewTagCommandErrors(t *testing.T) { {"image1"}, {"image1", "image2", "image3"}, } - expectedError := "\"tag\" requires exactly 2 arguments." + expectedError := "'tag' requires 2 arguments" for _, args := range testCases { cmd := NewTagCommand(test.NewFakeCli(&fakeClient{})) cmd.SetArgs(args) diff --git a/cli/command/manifest/annotate_test.go b/cli/command/manifest/annotate_test.go index 089b29c716..f2c924e45f 100644 --- a/cli/command/manifest/annotate_test.go +++ b/cli/command/manifest/annotate_test.go @@ -18,7 +18,7 @@ func TestManifestAnnotateError(t *testing.T) { }{ { args: []string{"too-few-arguments"}, - expectedError: "requires exactly 2 arguments", + expectedError: "requires 2 arguments", }, { args: []string{"th!si'sa/fa!ke/li$t/name", "example.com/alpine:3.0"}, diff --git a/cli/command/manifest/push_test.go b/cli/command/manifest/push_test.go index 2a11fceda2..a10d5b24db 100644 --- a/cli/command/manifest/push_test.go +++ b/cli/command/manifest/push_test.go @@ -31,7 +31,7 @@ func TestManifestPushErrors(t *testing.T) { }{ { args: []string{"one-arg", "extra-arg"}, - expectedError: "requires exactly 1 argument", + expectedError: "requires 1 argument", }, { args: []string{"th!si'sa/fa!ke/li$t/-name"}, diff --git a/cli/command/network/connect_test.go b/cli/command/network/connect_test.go index cfdff28806..c44fe3fc5f 100644 --- a/cli/command/network/connect_test.go +++ b/cli/command/network/connect_test.go @@ -19,7 +19,7 @@ func TestNetworkConnectErrors(t *testing.T) { expectedError string }{ { - expectedError: "requires exactly 2 arguments", + expectedError: "requires 2 arguments", }, { args: []string{"toto", "titi"}, diff --git a/cli/command/network/create_test.go b/cli/command/network/create_test.go index 8eab2ff0bd..348835f02a 100644 --- a/cli/command/network/create_test.go +++ b/cli/command/network/create_test.go @@ -21,7 +21,7 @@ func TestNetworkCreateErrors(t *testing.T) { expectedError string }{ { - expectedError: "exactly 1 argument", + expectedError: "1 argument", }, { args: []string{"toto"}, diff --git a/cli/command/network/disconnect_test.go b/cli/command/network/disconnect_test.go index bcbb491d09..bb82452a6c 100644 --- a/cli/command/network/disconnect_test.go +++ b/cli/command/network/disconnect_test.go @@ -17,7 +17,7 @@ func TestNetworkDisconnectErrors(t *testing.T) { expectedError string }{ { - expectedError: "requires exactly 2 arguments", + expectedError: "requires 2 arguments", }, { args: []string{"toto", "titi"}, diff --git a/cli/command/node/update_test.go b/cli/command/node/update_test.go index 09881d7ec2..52e771a9ae 100644 --- a/cli/command/node/update_test.go +++ b/cli/command/node/update_test.go @@ -20,11 +20,11 @@ func TestNodeUpdateErrors(t *testing.T) { expectedError string }{ { - expectedError: "requires exactly 1 argument", + expectedError: "requires 1 argument", }, { args: []string{"node1", "node2"}, - expectedError: "requires exactly 1 argument", + expectedError: "requires 1 argument", }, { args: []string{"nodeID"}, diff --git a/cli/command/plugin/disable_test.go b/cli/command/plugin/disable_test.go index 40bfab72ea..3920efa101 100644 --- a/cli/command/plugin/disable_test.go +++ b/cli/command/plugin/disable_test.go @@ -19,11 +19,11 @@ func TestPluginDisableErrors(t *testing.T) { }{ { args: []string{}, - expectedError: "requires exactly 1 argument", + expectedError: "requires 1 argument", }, { args: []string{"too", "many", "arguments"}, - expectedError: "requires exactly 1 argument", + expectedError: "requires 1 argument", }, { args: []string{"plugin-foo"}, diff --git a/cli/command/plugin/enable_test.go b/cli/command/plugin/enable_test.go index 20fa25f740..bb0861e6ce 100644 --- a/cli/command/plugin/enable_test.go +++ b/cli/command/plugin/enable_test.go @@ -20,11 +20,11 @@ func TestPluginEnableErrors(t *testing.T) { }{ { args: []string{}, - expectedError: "requires exactly 1 argument", + expectedError: "requires 1 argument", }, { args: []string{"too-many", "arguments"}, - expectedError: "requires exactly 1 argument", + expectedError: "requires 1 argument", }, { args: []string{"plugin-foo"}, diff --git a/cli/command/secret/remove_test.go b/cli/command/secret/remove_test.go index 6b0dfcc2cd..b5f4889a8c 100644 --- a/cli/command/secret/remove_test.go +++ b/cli/command/secret/remove_test.go @@ -20,7 +20,7 @@ func TestSecretRemoveErrors(t *testing.T) { }{ { args: []string{}, - expectedError: "requires at least 1 argument.", + expectedError: "requires at least 1 argument", }, { args: []string{"foo"}, diff --git a/cli/command/service/rollback_test.go b/cli/command/service/rollback_test.go index 742d9f99c4..28e7f27c68 100644 --- a/cli/command/service/rollback_test.go +++ b/cli/command/service/rollback_test.go @@ -65,12 +65,12 @@ func TestRollbackWithErrors(t *testing.T) { }{ { name: "not-enough-args", - expectedError: "requires exactly 1 argument", + expectedError: "requires 1 argument", }, { name: "too-many-args", args: []string{"service-id-1", "service-id-2"}, - expectedError: "requires exactly 1 argument", + expectedError: "requires 1 argument", }, { name: "service-does-not-exists", diff --git a/cli/command/stack/ps_test.go b/cli/command/stack/ps_test.go index e14002e210..009d51ed83 100644 --- a/cli/command/stack/ps_test.go +++ b/cli/command/stack/ps_test.go @@ -24,11 +24,11 @@ func TestStackPsErrors(t *testing.T) { }{ { args: []string{}, - expectedError: "requires exactly 1 argument", + expectedError: "requires 1 argument", }, { args: []string{"foo", "bar"}, - expectedError: "requires exactly 1 argument", + expectedError: "requires 1 argument", }, { args: []string{"foo"}, diff --git a/cli/command/swarm/join_test.go b/cli/command/swarm/join_test.go index 9a60e9e25e..6d60d693d2 100644 --- a/cli/command/swarm/join_test.go +++ b/cli/command/swarm/join_test.go @@ -23,12 +23,12 @@ func TestSwarmJoinErrors(t *testing.T) { }{ { name: "not-enough-args", - expectedError: "requires exactly 1 argument", + expectedError: "requires 1 argument", }, { name: "too-many-args", args: []string{"remote1", "remote2"}, - expectedError: "requires exactly 1 argument", + expectedError: "requires 1 argument", }, { name: "join-failed", diff --git a/cli/command/swarm/join_token_test.go b/cli/command/swarm/join_token_test.go index 21b89e6652..c97cc0012d 100644 --- a/cli/command/swarm/join_token_test.go +++ b/cli/command/swarm/join_token_test.go @@ -27,12 +27,12 @@ func TestSwarmJoinTokenErrors(t *testing.T) { }{ { name: "not-enough-args", - expectedError: "requires exactly 1 argument", + expectedError: "requires 1 argument", }, { name: "too-many-args", args: []string{"worker", "manager"}, - expectedError: "requires exactly 1 argument", + expectedError: "requires 1 argument", }, { name: "invalid-args", diff --git a/cli/command/trust/key_generate_test.go b/cli/command/trust/key_generate_test.go index 9781a53384..74fc3fed68 100644 --- a/cli/command/trust/key_generate_test.go +++ b/cli/command/trust/key_generate_test.go @@ -26,12 +26,12 @@ func TestTrustKeyGenerateErrors(t *testing.T) { }{ { name: "not-enough-args", - expectedError: "requires exactly 1 argument", + expectedError: "requires 1 argument", }, { name: "too-many-args", args: []string{"key-1", "key-2"}, - expectedError: "requires exactly 1 argument", + expectedError: "requires 1 argument", }, } diff --git a/cli/command/trust/key_load_test.go b/cli/command/trust/key_load_test.go index d32883fc62..4d9e737e08 100644 --- a/cli/command/trust/key_load_test.go +++ b/cli/command/trust/key_load_test.go @@ -34,13 +34,14 @@ func TestTrustKeyLoadErrors(t *testing.T) { }{ { name: "not-enough-args", - expectedError: "exactly 1 argument", + expectedError: "1 argument", + args: []string{}, expectedOutput: "", }, { name: "too-many-args", args: []string{"iamnotakey", "alsonotakey"}, - expectedError: "exactly 1 argument", + expectedError: "1 argument", expectedOutput: "", }, { diff --git a/cli/command/trust/revoke_test.go b/cli/command/trust/revoke_test.go index 7521a7bcf2..6e2ebd66bf 100644 --- a/cli/command/trust/revoke_test.go +++ b/cli/command/trust/revoke_test.go @@ -24,12 +24,12 @@ func TestTrustRevokeCommandErrors(t *testing.T) { }{ { name: "not-enough-args", - expectedError: "requires exactly 1 argument", + expectedError: "requires 1 argument", }, { name: "too-many-args", args: []string{"remote1", "remote2"}, - expectedError: "requires exactly 1 argument", + expectedError: "requires 1 argument", }, { name: "sha-reference", diff --git a/cli/command/trust/sign_test.go b/cli/command/trust/sign_test.go index 8249ad893f..7e8d0a08e7 100644 --- a/cli/command/trust/sign_test.go +++ b/cli/command/trust/sign_test.go @@ -32,12 +32,12 @@ func TestTrustSignCommandErrors(t *testing.T) { }{ { name: "not-enough-args", - expectedError: "requires exactly 1 argument", + expectedError: "requires 1 argument", }, { name: "too-many-args", args: []string{"image", "tag"}, - expectedError: "requires exactly 1 argument", + expectedError: "requires 1 argument", }, { name: "sha-reference", diff --git a/cli/required.go b/cli/required.go index ba4e6e8efa..8d01887d0f 100644 --- a/cli/required.go +++ b/cli/required.go @@ -22,11 +22,10 @@ func NoArgs(cmd *cobra.Command, args []string) error { } return errors.Errorf( - "%q accepts no arguments.\nSee '%s --help'.\n\nUsage: %s\n\n%s", - cmd.CommandPath(), + "%[1]s: '%[2]s' accepts no arguments\n\nUsage: %[3]s\n\nRun '%[2]s --help' for more information", + binName(cmd), cmd.CommandPath(), cmd.UseLine(), - cmd.Short, ) } @@ -37,13 +36,12 @@ func RequiresMinArgs(min int) cobra.PositionalArgs { return nil } return errors.Errorf( - "%q requires at least %d %s.\nSee '%s --help'.\n\nUsage: %s\n\n%s", + "%[1]s: '%[2]s' requires at least %[3]d %[4]s\n\nUsage: %[5]s\n\nSee '%[2]s --help' for more information", + binName(cmd), cmd.CommandPath(), min, pluralize("argument", min), - cmd.CommandPath(), cmd.UseLine(), - cmd.Short, ) } } @@ -55,13 +53,12 @@ func RequiresMaxArgs(max int) cobra.PositionalArgs { return nil } return errors.Errorf( - "%q requires at most %d %s.\nSee '%s --help'.\n\nUsage: %s\n\n%s", + "%[1]s: '%[2]s' requires at most %[3]d %[4]s\n\nUsage: %[5]s\n\nSRun '%[2]s --help' for more information", + binName(cmd), cmd.CommandPath(), max, pluralize("argument", max), - cmd.CommandPath(), cmd.UseLine(), - cmd.Short, ) } } @@ -73,14 +70,13 @@ func RequiresRangeArgs(min int, max int) cobra.PositionalArgs { return nil } return errors.Errorf( - "%q requires at least %d and at most %d %s.\nSee '%s --help'.\n\nUsage: %s\n\n%s", + "%[1]s: '%[2]s' requires at least %[3]d and at most %[4]d %[5]s\n\nUsage: %[6]s\n\nRun '%[2]s --help' for more information", + binName(cmd), cmd.CommandPath(), min, max, pluralize("argument", max), - cmd.CommandPath(), cmd.UseLine(), - cmd.Short, ) } } @@ -92,13 +88,12 @@ func ExactArgs(number int) cobra.PositionalArgs { return nil } return errors.Errorf( - "%q requires exactly %d %s.\nSee '%s --help'.\n\nUsage: %s\n\n%s", + "%[1]s: '%[2]s' requires %[3]d %[4]s\n\nUsage: %[5]s\n\nRun '%[2]s --help' for more information", + binName(cmd), cmd.CommandPath(), number, pluralize("argument", number), - cmd.CommandPath(), cmd.UseLine(), - cmd.Short, ) } } diff --git a/cli/required_test.go b/cli/required_test.go index 9c5fc0b0c8..795fb4589a 100644 --- a/cli/required_test.go +++ b/cli/required_test.go @@ -18,7 +18,7 @@ func TestRequiresNoArgs(t *testing.T) { { args: []string{"foo"}, validateFunc: NoArgs, - expectedError: "accepts no arguments.", + expectedError: "accepts no arguments", }, } for _, tc := range testCases { @@ -36,12 +36,12 @@ func TestRequiresMinArgs(t *testing.T) { }, { validateFunc: RequiresMinArgs(1), - expectedError: "at least 1 argument.", + expectedError: "at least 1 argument", }, { args: []string{"foo"}, validateFunc: RequiresMinArgs(2), - expectedError: "at least 2 arguments.", + expectedError: "at least 2 arguments", }, } for _, tc := range testCases { @@ -60,12 +60,12 @@ func TestRequiresMaxArgs(t *testing.T) { { args: []string{"foo", "bar"}, validateFunc: RequiresMaxArgs(1), - expectedError: "at most 1 argument.", + expectedError: "at most 1 argument", }, { args: []string{"foo", "bar", "baz"}, validateFunc: RequiresMaxArgs(2), - expectedError: "at most 2 arguments.", + expectedError: "at most 2 arguments", }, } for _, tc := range testCases { @@ -88,12 +88,12 @@ func TestRequiresRangeArgs(t *testing.T) { { args: []string{"foo", "bar"}, validateFunc: RequiresRangeArgs(0, 1), - expectedError: "at most 1 argument.", + expectedError: "at most 1 argument", }, { args: []string{"foo", "bar", "baz"}, validateFunc: RequiresRangeArgs(0, 2), - expectedError: "at most 2 arguments.", + expectedError: "at most 2 arguments", }, { validateFunc: RequiresRangeArgs(1, 2), @@ -115,11 +115,11 @@ func TestExactArgs(t *testing.T) { }, { validateFunc: ExactArgs(1), - expectedError: "exactly 1 argument.", + expectedError: "1 argument", }, { validateFunc: ExactArgs(2), - expectedError: "exactly 2 arguments.", + expectedError: "2 arguments", }, } for _, tc := range testCases { diff --git a/cmd/docker/docker_test.go b/cmd/docker/docker_test.go index 84ea272a20..1998b77c99 100644 --- a/cmd/docker/docker_test.go +++ b/cmd/docker/docker_test.go @@ -66,7 +66,7 @@ func TestExitStatusForInvalidSubcommandWithHelpFlag(t *testing.T) { func TestExitStatusForInvalidSubcommand(t *testing.T) { err := runCliCommand(t, nil, nil, "invalid") - assert.Check(t, is.ErrorContains(err, "docker: 'docker invalid' is not a docker command.")) + assert.Check(t, is.ErrorContains(err, "docker: unknown command: docker invalid")) } func TestVersion(t *testing.T) { diff --git a/e2e/cli-plugins/flags_test.go b/e2e/cli-plugins/flags_test.go index 836af32e2a..c4e5fbcbc4 100644 --- a/e2e/cli-plugins/flags_test.go +++ b/e2e/cli-plugins/flags_test.go @@ -180,14 +180,14 @@ func TestCliPluginsVersion(t *testing.T) { args: []string{"version", "foo"}, expCode: 1, expOut: icmd.None, - expErr: `"docker version" accepts no arguments.`, + expErr: `docker: 'docker version' accepts no arguments`, }, { name: "global-with-plugin-arg", args: []string{"version", "helloworld"}, expCode: 1, expOut: icmd.None, - expErr: `"docker version" accepts no arguments.`, + expErr: `docker: 'docker version' accepts no arguments`, }, { name: "global-version-flag-with-unknown-arg",