当前位置: 首页>>代码示例>>Golang>>正文


Golang Command.Name方法代码示例

本文整理汇总了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)
}
开发者ID:ngorskig,项目名称:rkt,代码行数:31,代码来源:stage1hash.go

示例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)
}
开发者ID:matomesc,项目名称:rkt,代码行数:32,代码来源:stage1hash.go


注:本文中的github.com/coreos/rkt/Godeps/_workspace/src/github.com/spf13/cobra.Command.Name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。