mirror of https://github.com/docker/docs.git
Cosmetic: renamed the variable for sub-command argument parsing, to avoid confusion between 'flag' and 'flags'
This commit is contained in:
parent
db6ba2b908
commit
5926cfd0ec
|
@ -255,11 +255,11 @@ func (srv *Server) CmdRmi(stdin io.ReadCloser, stdout io.Writer, args ...string)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (srv *Server) CmdRm(stdin io.ReadCloser, stdout io.Writer, args ...string) error {
|
func (srv *Server) CmdRm(stdin io.ReadCloser, stdout io.Writer, args ...string) error {
|
||||||
flags := rcli.Subcmd(stdout, "rm", "[OPTIONS] CONTAINER", "Remove a container")
|
cmd := rcli.Subcmd(stdout, "rm", "[OPTIONS] CONTAINER", "Remove a container")
|
||||||
if err := flags.Parse(args); err != nil {
|
if err := cmd.Parse(args); err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
for _, name := range flags.Args() {
|
for _, name := range cmd.Args() {
|
||||||
container := srv.containers.Get(name)
|
container := srv.containers.Get(name)
|
||||||
if container == nil {
|
if container == nil {
|
||||||
return errors.New("No such container: " + name)
|
return errors.New("No such container: " + name)
|
||||||
|
@ -300,17 +300,17 @@ func (srv *Server) CmdPut(stdin io.ReadCloser, stdout io.Writer, args ...string)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (srv *Server) CmdImages(stdin io.ReadCloser, stdout io.Writer, args ...string) error {
|
func (srv *Server) CmdImages(stdin io.ReadCloser, stdout io.Writer, args ...string) error {
|
||||||
flags := rcli.Subcmd(stdout, "images", "[OPTIONS] [NAME]", "List images")
|
cmd := rcli.Subcmd(stdout, "images", "[OPTIONS] [NAME]", "List images")
|
||||||
limit := flags.Int("l", 0, "Only show the N most recent versions of each image")
|
limit := cmd.Int("l", 0, "Only show the N most recent versions of each image")
|
||||||
quiet := flags.Bool("q", false, "only show numeric IDs")
|
quiet := cmd.Bool("q", false, "only show numeric IDs")
|
||||||
flags.Parse(args)
|
cmd.Parse(args)
|
||||||
if flags.NArg() > 1 {
|
if cmd.NArg() > 1 {
|
||||||
flags.Usage()
|
cmd.Usage()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
var nameFilter string
|
var nameFilter string
|
||||||
if flags.NArg() == 1 {
|
if cmd.NArg() == 1 {
|
||||||
nameFilter = flags.Arg(0)
|
nameFilter = cmd.Arg(0)
|
||||||
}
|
}
|
||||||
w := tabwriter.NewWriter(stdout, 20, 1, 3, ' ', 0)
|
w := tabwriter.NewWriter(stdout, 20, 1, 3, ' ', 0)
|
||||||
if (!*quiet) {
|
if (!*quiet) {
|
||||||
|
@ -403,10 +403,10 @@ func (srv *Server) CmdPs(stdin io.ReadCloser, stdout io.Writer, args ...string)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (srv *Server) CmdLayers(stdin io.ReadCloser, stdout io.Writer, args ...string) error {
|
func (srv *Server) CmdLayers(stdin io.ReadCloser, stdout io.Writer, args ...string) error {
|
||||||
flags := rcli.Subcmd(stdout,
|
cmd := rcli.Subcmd(stdout,
|
||||||
"layers", "[OPTIONS]",
|
"layers", "[OPTIONS]",
|
||||||
"List filesystem layers (debug only)")
|
"List filesystem layers (debug only)")
|
||||||
if err := flags.Parse(args); err != nil {
|
if err := cmd.Parse(args); err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
for _, layer := range srv.images.Layers.List() {
|
for _, layer := range srv.images.Layers.List() {
|
||||||
|
@ -417,13 +417,13 @@ func (srv *Server) CmdLayers(stdin io.ReadCloser, stdout io.Writer, args ...stri
|
||||||
|
|
||||||
|
|
||||||
func (srv *Server) CmdCp(stdin io.ReadCloser, stdout io.Writer, args ...string) error {
|
func (srv *Server) CmdCp(stdin io.ReadCloser, stdout io.Writer, args ...string) error {
|
||||||
flags := rcli.Subcmd(stdout,
|
cmd := rcli.Subcmd(stdout,
|
||||||
"cp", "[OPTIONS] IMAGE NAME",
|
"cp", "[OPTIONS] IMAGE NAME",
|
||||||
"Create a copy of IMAGE and call it NAME")
|
"Create a copy of IMAGE and call it NAME")
|
||||||
if err := flags.Parse(args); err != nil {
|
if err := cmd.Parse(args); err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if newImage, err := srv.images.Copy(flags.Arg(0), flags.Arg(1)); err != nil {
|
if newImage, err := srv.images.Copy(cmd.Arg(0), cmd.Arg(1)); err != nil {
|
||||||
return err
|
return err
|
||||||
} else {
|
} else {
|
||||||
fmt.Fprintln(stdout, newImage.Id)
|
fmt.Fprintln(stdout, newImage.Id)
|
||||||
|
@ -432,15 +432,15 @@ func (srv *Server) CmdCp(stdin io.ReadCloser, stdout io.Writer, args ...string)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (srv *Server) CmdCommit(stdin io.ReadCloser, stdout io.Writer, args ...string) error {
|
func (srv *Server) CmdCommit(stdin io.ReadCloser, stdout io.Writer, args ...string) error {
|
||||||
flags := rcli.Subcmd(stdout,
|
cmd := rcli.Subcmd(stdout,
|
||||||
"commit", "[OPTIONS] CONTAINER [DEST]",
|
"commit", "[OPTIONS] CONTAINER [DEST]",
|
||||||
"Create a new image from a container's changes")
|
"Create a new image from a container's changes")
|
||||||
if err := flags.Parse(args); err != nil {
|
if err := cmd.Parse(args); err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
containerName, imgName := flags.Arg(0), flags.Arg(1)
|
containerName, imgName := cmd.Arg(0), cmd.Arg(1)
|
||||||
if containerName == "" || imgName == "" {
|
if containerName == "" || imgName == "" {
|
||||||
flags.Usage()
|
cmd.Usage()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if container := srv.containers.Get(containerName); container != nil {
|
if container := srv.containers.Get(containerName); container != nil {
|
||||||
|
@ -463,17 +463,17 @@ func (srv *Server) CmdCommit(stdin io.ReadCloser, stdout io.Writer, args ...stri
|
||||||
|
|
||||||
|
|
||||||
func (srv *Server) CmdTar(stdin io.ReadCloser, stdout io.Writer, args ...string) error {
|
func (srv *Server) CmdTar(stdin io.ReadCloser, stdout io.Writer, args ...string) error {
|
||||||
flags := rcli.Subcmd(stdout,
|
cmd := rcli.Subcmd(stdout,
|
||||||
"tar", "CONTAINER",
|
"tar", "CONTAINER",
|
||||||
"Stream the contents of a container as a tar archive")
|
"Stream the contents of a container as a tar archive")
|
||||||
fl_sparse := flags.Bool("s", false, "Generate a sparse tar stream (top layer + reference to bottom layers)")
|
fl_sparse := cmd.Bool("s", false, "Generate a sparse tar stream (top layer + reference to bottom layers)")
|
||||||
if err := flags.Parse(args); err != nil {
|
if err := cmd.Parse(args); err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if *fl_sparse {
|
if *fl_sparse {
|
||||||
return errors.New("Sparse mode not yet implemented") // FIXME
|
return errors.New("Sparse mode not yet implemented") // FIXME
|
||||||
}
|
}
|
||||||
name := flags.Arg(0)
|
name := cmd.Arg(0)
|
||||||
if container := srv.containers.Get(name); container != nil {
|
if container := srv.containers.Get(name); container != nil {
|
||||||
data, err := container.Filesystem.Tar()
|
data, err := container.Filesystem.Tar()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -489,16 +489,16 @@ func (srv *Server) CmdTar(stdin io.ReadCloser, stdout io.Writer, args ...string)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (srv *Server) CmdDiff(stdin io.ReadCloser, stdout io.Writer, args ...string) error {
|
func (srv *Server) CmdDiff(stdin io.ReadCloser, stdout io.Writer, args ...string) error {
|
||||||
flags := rcli.Subcmd(stdout,
|
cmd := rcli.Subcmd(stdout,
|
||||||
"diff", "CONTAINER [OPTIONS]",
|
"diff", "CONTAINER [OPTIONS]",
|
||||||
"Inspect changes on a container's filesystem")
|
"Inspect changes on a container's filesystem")
|
||||||
if err := flags.Parse(args); err != nil {
|
if err := cmd.Parse(args); err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if flags.NArg() < 1 {
|
if cmd.NArg() < 1 {
|
||||||
return errors.New("Not enough arguments")
|
return errors.New("Not enough arguments")
|
||||||
}
|
}
|
||||||
if container := srv.containers.Get(flags.Arg(0)); container == nil {
|
if container := srv.containers.Get(cmd.Arg(0)); container == nil {
|
||||||
return errors.New("No such container")
|
return errors.New("No such container")
|
||||||
} else {
|
} else {
|
||||||
changes, err := container.Filesystem.Changes()
|
changes, err := container.Filesystem.Changes()
|
||||||
|
@ -513,16 +513,16 @@ func (srv *Server) CmdDiff(stdin io.ReadCloser, stdout io.Writer, args ...string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (srv *Server) CmdReset(stdin io.ReadCloser, stdout io.Writer, args ...string) error {
|
func (srv *Server) CmdReset(stdin io.ReadCloser, stdout io.Writer, args ...string) error {
|
||||||
flags := rcli.Subcmd(stdout,
|
cmd := rcli.Subcmd(stdout,
|
||||||
"reset", "CONTAINER [OPTIONS]",
|
"reset", "CONTAINER [OPTIONS]",
|
||||||
"Reset changes to a container's filesystem")
|
"Reset changes to a container's filesystem")
|
||||||
if err := flags.Parse(args); err != nil {
|
if err := cmd.Parse(args); err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if flags.NArg() < 1 {
|
if cmd.NArg() < 1 {
|
||||||
return errors.New("Not enough arguments")
|
return errors.New("Not enough arguments")
|
||||||
}
|
}
|
||||||
for _, name := range flags.Args() {
|
for _, name := range cmd.Args() {
|
||||||
if container := srv.containers.Get(name); container != nil {
|
if container := srv.containers.Get(name); container != nil {
|
||||||
if err := container.Filesystem.Reset(); err != nil {
|
if err := container.Filesystem.Reset(); err != nil {
|
||||||
return errors.New("Reset " + container.Id + ": " + err.Error())
|
return errors.New("Reset " + container.Id + ": " + err.Error())
|
||||||
|
@ -534,15 +534,15 @@ func (srv *Server) CmdReset(stdin io.ReadCloser, stdout io.Writer, args ...strin
|
||||||
|
|
||||||
|
|
||||||
func (srv *Server) CmdLogs(stdin io.ReadCloser, stdout io.Writer, args ...string) error {
|
func (srv *Server) CmdLogs(stdin io.ReadCloser, stdout io.Writer, args ...string) error {
|
||||||
flags := rcli.Subcmd(stdout, "logs", "[OPTIONS] CONTAINER", "Fetch the logs of a container")
|
cmd := rcli.Subcmd(stdout, "logs", "[OPTIONS] CONTAINER", "Fetch the logs of a container")
|
||||||
if err := flags.Parse(args); err != nil {
|
if err := cmd.Parse(args); err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if flags.NArg() != 1 {
|
if cmd.NArg() != 1 {
|
||||||
flags.Usage()
|
cmd.Usage()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
name := flags.Arg(0)
|
name := cmd.Arg(0)
|
||||||
if container := srv.containers.Get(name); container != nil {
|
if container := srv.containers.Get(name); container != nil {
|
||||||
if _, err := io.Copy(stdout, container.StdoutLog()); err != nil {
|
if _, err := io.Copy(stdout, container.StdoutLog()); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -552,7 +552,7 @@ func (srv *Server) CmdLogs(stdin io.ReadCloser, stdout io.Writer, args ...string
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return errors.New("No such container: " + flags.Arg(0))
|
return errors.New("No such container: " + cmd.Arg(0))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -621,29 +621,29 @@ func (srv *Server) CmdAttach(stdin io.ReadCloser, stdout io.Writer, args ...stri
|
||||||
}
|
}
|
||||||
|
|
||||||
func (srv *Server) CmdRun(stdin io.ReadCloser, stdout io.Writer, args ...string) error {
|
func (srv *Server) CmdRun(stdin io.ReadCloser, stdout io.Writer, args ...string) error {
|
||||||
flags := rcli.Subcmd(stdout, "run", "[OPTIONS] IMAGE COMMAND [ARG...]", "Run a command in a new container")
|
cmd := rcli.Subcmd(stdout, "run", "[OPTIONS] IMAGE COMMAND [ARG...]", "Run a command in a new container")
|
||||||
fl_attach := flags.Bool("a", false, "Attach stdin and stdout")
|
fl_attach := cmd.Bool("a", false, "Attach stdin and stdout")
|
||||||
fl_stdin := flags.Bool("i", false, "Keep stdin open even if not attached")
|
fl_stdin := cmd.Bool("i", false, "Keep stdin open even if not attached")
|
||||||
fl_tty := flags.Bool("t", false, "Allocate a pseudo-tty")
|
fl_tty := cmd.Bool("t", false, "Allocate a pseudo-tty")
|
||||||
fl_comment := flags.String("c", "", "Comment")
|
fl_comment := cmd.String("c", "", "Comment")
|
||||||
if err := flags.Parse(args); err != nil {
|
if err := cmd.Parse(args); err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
name := flags.Arg(0)
|
name := cmd.Arg(0)
|
||||||
var cmd[]string
|
var cmdline[]string
|
||||||
if len(flags.Args()) >= 2 {
|
if len(cmd.Args()) >= 2 {
|
||||||
cmd = flags.Args()[1:]
|
cmdline = cmd.Args()[1:]
|
||||||
}
|
}
|
||||||
// Choose a default image if needed
|
// Choose a default image if needed
|
||||||
if name == "" {
|
if name == "" {
|
||||||
name = "base"
|
name = "base"
|
||||||
}
|
}
|
||||||
// Choose a default command if needed
|
// Choose a default command if needed
|
||||||
if len(cmd) == 0 {
|
if len(cmdline) == 0 {
|
||||||
*fl_stdin = true
|
*fl_stdin = true
|
||||||
*fl_tty = true
|
*fl_tty = true
|
||||||
*fl_attach = true
|
*fl_attach = true
|
||||||
cmd = []string{"/bin/bash", "-i"}
|
cmdline = []string{"/bin/bash", "-i"}
|
||||||
}
|
}
|
||||||
// Find the image
|
// Find the image
|
||||||
img := srv.images.Find(name)
|
img := srv.images.Find(name)
|
||||||
|
@ -651,7 +651,7 @@ func (srv *Server) CmdRun(stdin io.ReadCloser, stdout io.Writer, args ...string)
|
||||||
return errors.New("No such image: " + name)
|
return errors.New("No such image: " + name)
|
||||||
}
|
}
|
||||||
// Create new container
|
// Create new container
|
||||||
container, err := srv.CreateContainer(img, *fl_tty, *fl_stdin, *fl_comment, cmd[0], cmd[1:]...)
|
container, err := srv.CreateContainer(img, *fl_tty, *fl_stdin, *fl_comment, cmdline[0], cmdline[1:]...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.New("Error creating container: " + err.Error())
|
return errors.New("Error creating container: " + err.Error())
|
||||||
}
|
}
|
||||||
|
@ -764,9 +764,9 @@ func (srv *Server) CmdDebug(stdin io.ReadCloser, stdout io.Writer, args ...strin
|
||||||
}
|
}
|
||||||
|
|
||||||
func (srv *Server) CmdWeb(stdin io.ReadCloser, stdout io.Writer, args ...string) error {
|
func (srv *Server) CmdWeb(stdin io.ReadCloser, stdout io.Writer, args ...string) error {
|
||||||
flags := rcli.Subcmd(stdout, "web", "[OPTIONS]", "A web UI for docker")
|
cmd := rcli.Subcmd(stdout, "web", "[OPTIONS]", "A web UI for docker")
|
||||||
showurl := flags.Bool("u", false, "Return the URL of the web UI")
|
showurl := cmd.Bool("u", false, "Return the URL of the web UI")
|
||||||
if err := flags.Parse(args); err != nil {
|
if err := cmd.Parse(args); err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if *showurl {
|
if *showurl {
|
||||||
|
|
Loading…
Reference in New Issue