Fixup create command flag application.

Previously StringSlice flag defaults were not respected.  These use
special handling and that handling did not take account of default
values, always over-writing them.  Expand the CommandLine interface to
take advantage of the underlying codegansta/cli.Context IsSet method and
guard default string slice overwrites with an IsSet test.

Signed-off-by: John Sirois <john.sirois@gmail.com>
This commit is contained in:
John Sirois 2016-03-29 11:36:28 -06:00
parent 0d58079bf5
commit 705865fa70
3 changed files with 10 additions and 1 deletions

View File

@ -42,6 +42,8 @@ type CommandLine interface {
Args() cli.Args
IsSet(name string) bool
Bool(name string) bool
Int(name string) int

View File

@ -42,6 +42,11 @@ func (ff FakeFlagger) Bool(key string) bool {
return false
}
func (fcli *FakeCommandLine) IsSet(key string) bool {
_, ok := fcli.LocalFlags.Data[key]
return ok
}
func (fcli *FakeCommandLine) String(key string) string {
return fcli.LocalFlags.String(key)
}

View File

@ -364,7 +364,9 @@ func getDriverOpts(c CommandLine, mcnflags []mcnflag.Flag) drivers.DriverOptions
// TODO: This is pretty hacky. StringSlice is the only
// type so far we have to worry about which is not a
// Getter, though.
driverOpts.Values[name] = c.StringSlice(name)
if c.IsSet(name) {
driverOpts.Values[name] = c.StringSlice(name)
}
}
}