Skip to content

Instantly share code, notes, and snippets.

@dmcgowan
Last active July 8, 2016 17:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmcgowan/cb31438ef1c90d74371300715c4c48b4 to your computer and use it in GitHub Desktop.
Save dmcgowan/cb31438ef1c90d74371300715c4c48b4 to your computer and use it in GitHub Desktop.
Use `--` to specify variadic positional arguments
diff --git a/api/client/service/update.go b/api/client/service/update.go
index dc6e34c..f35bc17 100644
--- a/api/client/service/update.go
+++ b/api/client/service/update.go
@@ -2,6 +2,7 @@ package service
import (
"fmt"
+ "strings"
"time"
"golang.org/x/net/context"
@@ -25,19 +26,26 @@ func newUpdateCommand(dockerCli *client.DockerCli) *cobra.Command {
var opts updateOptions
cmd := &cobra.Command{
- Use: "update [OPTIONS] SERVICE [ARG...]",
+ Use: "update [OPTIONS] SERVICE [--] [ARG...]",
Short: "Update a service",
Args: cli.RequiresMinArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
opts.serviceID = args[0]
if len(args) > 1 {
- opts.args = args[1:]
+ if strings.HasPrefix(args[1], "-") && args[1] != "--" {
+ return cmd.Help()
+ } else if args[1] == "--" {
+ opts.args = args[2:]
+ } else {
+ opts.args = args[1:]
+ }
}
return runUpdate(dockerCli, cmd.Flags(), opts)
},
}
flags := cmd.Flags()
+ flags.SetInterspersed(false)
flags.String("image", "", "Service image tag")
// TODO: make this entrypoint and share with create
flags.StringSlice("command", []string{}, "Service command")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment