本文整理匯總了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)
}