Fix `docker volume invalid` so it displays usage

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
This commit is contained in:
Brian Goff 2015-08-26 20:31:31 -04:00
Родитель 44ea7e91fb
Коммит 38da43184d
2 изменённых файлов: 14 добавлений и 0 удалений

Просмотреть файл

@ -34,6 +34,7 @@ func (cli *DockerCli) CmdVolume(args ...string) error {
description += "\nRun 'docker volume COMMAND --help' for more information on a command." description += "\nRun 'docker volume COMMAND --help' for more information on a command."
cmd := Cli.Subcmd("volume", []string{"[COMMAND]"}, description, true) cmd := Cli.Subcmd("volume", []string{"[COMMAND]"}, description, true)
cmd.Require(flag.Exact, 0)
cmd.ParseFlags(args, true) cmd.ParseFlags(args, true)
return cli.CmdVolumeLs(args...) return cli.CmdVolumeLs(args...)

Просмотреть файл

@ -88,3 +88,16 @@ func (s *DockerSuite) TestVolumeCliRm(c *check.C) {
check.Commentf("volume rm should fail with non-existant volume"), check.Commentf("volume rm should fail with non-existant volume"),
) )
} }
func (s *DockerSuite) TestVolumeCliNoArgs(c *check.C) {
out, _ := dockerCmd(c, "volume")
// no args should produce the `volume ls` output
c.Assert(strings.Contains(out, "DRIVER"), check.Equals, true)
// invalid arg should error and show the command usage on stderr
_, stderr, _, err := runCommandWithStdoutStderr(exec.Command(dockerBinary, "volume", "somearg"))
c.Assert(err, check.NotNil)
expected := "Usage: docker volume [OPTIONS] [COMMAND]"
c.Assert(strings.Contains(stderr, expected), check.Equals, true)
}