本文整理匯總了Golang中github.com/docker/machine/cli.Context.FlagNames方法的典型用法代碼示例。如果您正苦於以下問題:Golang Context.FlagNames方法的具體用法?Golang Context.FlagNames怎麽用?Golang Context.FlagNames使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/docker/machine/cli.Context
的用法示例。
在下文中一共展示了Context.FlagNames方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: getDriverOpts
func getDriverOpts(c *cli.Context, mcnflags []mcnflag.Flag) drivers.DriverOptions {
// TODO: This function is pretty damn YOLO and would benefit from some
// sanity checking around types and assertions.
//
// But, we need it so that we can actually send the flags for creating
// a machine over the wire (cli.Context is a no go since there is so
// much stuff in it).
driverOpts := rpcdriver.RpcFlags{
Values: make(map[string]interface{}),
}
for _, f := range mcnflags {
driverOpts.Values[f.String()] = f.Default()
// Hardcoded logic for boolean... :(
if f.Default() == nil {
driverOpts.Values[f.String()] = false
}
}
for _, name := range c.FlagNames() {
getter, ok := c.Generic(name).(flag.Getter)
if !ok {
// 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)
continue
}
driverOpts.Values[name] = getter.Get()
}
return driverOpts
}