本文整理汇总了Golang中github.com/coreos/rkt/Godeps/_workspace/src/github.com/spf13/cobra.Command.Name方法的典型用法代码示例。如果您正苦于以下问题:Golang Command.Name方法的具体用法?Golang Command.Name怎么用?Golang Command.Name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/coreos/rkt/Godeps/_workspace/src/github.com/spf13/cobra.Command
的用法示例。
在下文中一共展示了Command.Name方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: getStage1Hash
// getStage1Hash will try to fetch stage1 from store if it is a
// default one. If that fails it will try to get via usual fetching
// from disk or network.
//
// As a special case, if stage1 image path is a default and not
// overriden by --stage1-image flag and it is has no scheme, it will
// try to fetch it from two places on disk - from the path directly if
// it is absolute and then from the same directory where rkt binary
// resides.
//
// The passed command must have "stage1-image" string flag registered.
func getStage1Hash(s *store.Store, cmd *cobra.Command) (*types.Hash, error) {
fn := &finder{
imageActionData: imageActionData{
s: s,
},
storeOnly: false,
noStore: false,
withDeps: false,
}
imageFlag := cmd.Flags().Lookup(stage1ImageFlagName)
if imageFlag == nil {
panic(fmt.Sprintf("Expected flag --%s to be registered in command %s", stage1ImageFlagName, cmd.Name()))
}
path := imageFlag.Value.String()
if path == defaultStage1Image {
return getDefaultStage1Hash(fn, imageFlag.Changed)
}
return getCustomStage1Hash(fn, path)
}
示例2: getStage1Hash
// getStage1Hash will try to fetch stage1 from store if it is a
// default one. If that fails it will try to get via usual fetching
// from disk or network.
//
// As a special case, if stage1 image path is a default and not
// overriden by --stage1-image flag and it is has no scheme, it will
// try to fetch it from two places on disk - from the path directly if
// it is absolute and then from the same directory where rkt binary
// resides.
//
// The passed command must have "stage1-image" string flag registered.
func getStage1Hash(s *store.Store, cmd *cobra.Command) (*types.Hash, error) {
fn := &image.Finder{
S: s,
InsecureFlags: globalFlags.InsecureFlags,
TrustKeysFromHttps: globalFlags.TrustKeysFromHttps,
StoreOnly: false,
NoStore: false,
WithDeps: false,
}
imageFlag := cmd.Flags().Lookup(stage1ImageFlagName)
if imageFlag == nil {
panic(fmt.Sprintf("Expected flag --%s to be registered in command %s", stage1ImageFlagName, cmd.Name()))
}
path := imageFlag.Value.String()
if path == defaultStage1Image {
return getDefaultStage1Hash(fn, imageFlag.Changed)
}
return getCustomStage1Hash(fn, path)
}