1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

allow multiple params in inspect

This commit is contained in:
Victor Vieux 2013-06-06 15:22:54 +00:00
parent f1992eeea5
commit a799cdad3e

View file

@ -512,28 +512,33 @@ func (cli *DockerCli) CmdStart(args ...string) error {
}
func (cli *DockerCli) CmdInspect(args ...string) error {
cmd := Subcmd("inspect", "CONTAINER|IMAGE", "Return low-level information on a container/image")
cmd := Subcmd("inspect", "CONTAINER|IMAGE [CONTAINER|IMAGE...]", "Return low-level information on a container/image")
if err := cmd.Parse(args); err != nil {
return nil
}
if cmd.NArg() != 1 {
if cmd.NArg() < 1 {
cmd.Usage()
return nil
}
obj, _, err := cli.call("GET", "/containers/"+cmd.Arg(0)+"/json", nil)
for _, name := range args {
obj, _, err := cli.call("GET", "/containers/"+name+"/json", nil)
if err != nil {
obj, _, err = cli.call("GET", "/images/"+cmd.Arg(0)+"/json", nil)
obj, _, err = cli.call("GET", "/images/"+name+"/json", nil)
if err != nil {
return err
fmt.Printf("%s", err)
continue
}
}
indented := new(bytes.Buffer)
if err = json.Indent(indented, obj, "", " "); err != nil {
return err
fmt.Printf("%s", err)
continue
}
if _, err := io.Copy(os.Stdout, indented); err != nil {
return err
fmt.Printf("%s", err)
}
}
return nil
}