本文整理汇总了Golang中github.com/spf13/cobra.OnInitialize函数的典型用法代码示例。如果您正苦于以下问题:Golang OnInitialize函数的具体用法?Golang OnInitialize怎么用?Golang OnInitialize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了OnInitialize函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: init
func init() {
cobra.OnInitialize(initConfig)
RootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default $HOME/.lateral/config.yaml)")
RootCmd.PersistentFlags().StringP("socket", "s", "", "UNIX domain socket path (default $HOME/.lateral/socket.$SESSIONID)")
Viper.BindPFlag("socket", RootCmd.PersistentFlags().Lookup("socket"))
}
开发者ID:akramer,项目名称:lateral,代码行数:7,代码来源:root.go
示例2: init
func init() {
cobra.OnInitialize(initConfig)
// Setting flags here so they can be used by both the root behavior as well as
// by the indidual behaviors of icarus and daedalus
RootCmd.PersistentFlags().StringVar(&CfgFile, "config", "", "config file (default is $CWD/config.yaml)")
RootCmd.PersistentFlags().IntP("port", "p", 8013, "Port run on")
RootCmd.PersistentFlags().IntP("width", "x", 15, "width of the laybrinth")
RootCmd.PersistentFlags().IntP("height", "y", 10, "height of the laybrinth") // 'h' is used for help already
RootCmd.PersistentFlags().IntP("times", "t", 1, "times to solve the laybrinth")
RootCmd.PersistentFlags().IntP("max-steps", "m", 500, "Maximum steps before giving up")
RootCmd.PersistentFlags().Bool("mouse", false, "Use random mouse solver")
RootCmd.PersistentFlags().String("bias", "O", "Bias for maze generator. H,V,X,O or D")
// Bind viper to these flags so viper can read flag values along with config, env, etc.
viper.BindPFlag("width", RootCmd.PersistentFlags().Lookup("width"))
viper.BindPFlag("height", RootCmd.PersistentFlags().Lookup("height"))
viper.BindPFlag("port", RootCmd.PersistentFlags().Lookup("port"))
viper.BindPFlag("times", RootCmd.PersistentFlags().Lookup("times"))
viper.BindPFlag("max-steps", RootCmd.PersistentFlags().Lookup("max-steps"))
viper.BindPFlag("mouse", RootCmd.PersistentFlags().Lookup("mouse"))
viper.BindPFlag("bias", RootCmd.PersistentFlags().Lookup("bias"))
}
开发者ID:captncraig,项目名称:gc6,代码行数:25,代码来源:labyrinth.go
示例3: init
func init() {
cobra.OnInitialize(initConfig)
// Here you will define your flags and configuration settings.
// Cobra supports Persistent Flags, which, if defined here,
// will be global for your application.
RootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.alea.yaml)")
RootCmd.PersistentFlags().StringVar(&cfg.controller, "controller", "", "alea controller URL, set it manually if it can't be resolved from the deis git remote, defaults to services.<deis.domain>")
RootCmd.Flags().StringVarP(&cfg.app, "app", "a", "", "deis app name, set it manually if it can't be resolved from the deis git remote")
// Cobra also supports local flags, which will only run
// when this action is called directly.
// RootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
if cfg.app == "" {
app, err := git.GetAppFromRemote()
if err != nil {
fmt.Println("Could not get App from git remote\n\nRun this command from the root of your Deis app for best results or pass in -a <app-name>\n\n")
}
cfg.app = app
}
}
开发者ID:Codaisseur,项目名称:deis-backing-services,代码行数:25,代码来源:root.go
示例4: init
func init() {
cobra.OnInitialize(initConfig)
// Command flags
RootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.goigc.yaml)")
}
开发者ID:rochaporto,项目名称:goigc,代码行数:7,代码来源:root.go
示例5: init
func init() {
cobra.OnInitialize(initConfig)
// Setup logging for the package. Doing it here is much eaiser than in each
// binary. If you want to overwrite it in a specific binary then feel free.
hook, err := logrus_syslog.NewSyslogHook("", "", syslog.LOG_INFO, "")
if err != nil {
panic(err)
}
syslogLog.Hooks.Add(hook)
syslogLog.Formatter = new(logrus.JSONFormatter)
// Set the hostname for use in logging within the package. Doing it here is
// cleaner than in each binary but if you want to use some other method just
// override the variable in the specific binary.
host, err = os.Hostname()
if err != nil {
syslogLog.WithFields(logrus.Fields{
"check": "sensupluginses",
"client": "unknown",
"version": version.AppVersion(),
"error": err,
}).Error(`Could not determine the hostname of this machine as reported by the kernel.`)
sensuutil.Exit("GENERALGOLANGERROR")
}
RootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.sensupluginses.yaml)")
RootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}
开发者ID:yieldbot,项目名称:sensupluginses,代码行数:29,代码来源:root.go
示例6: init
func init() {
credential = common.NewCredentialCobra(RootCmd)
cli.OnInitialize(initConfig)
RootCmd.AddCommand(hostCmd)
RootCmd.AddCommand(tenantCmd)
RootCmd.AddCommand(segmentCmd)
RootCmd.AddCommand(policyCmd)
RootCmd.Flags().BoolVarP(&version, "version", "",
false, "Build and Versioning Information.")
RootCmd.PersistentFlags().StringVarP(&cfgFile, "config",
"c", "", "config file (default is $HOME/.romana.yaml)")
RootCmd.PersistentFlags().StringVarP(&rootURL, "rootURL",
"r", "", "root service url, e.g. http://192.168.0.1")
RootCmd.PersistentFlags().StringVarP(&rootPort, "rootPort",
"p", "", "root service port, e.g. 9600")
RootCmd.PersistentFlags().StringVarP(&format, "format",
"f", "", "enable formatting options like [json|table], etc.")
RootCmd.PersistentFlags().StringVarP(&platform, "platform",
"P", "", "Use platforms like [openstack|kubernetes], etc.")
RootCmd.PersistentFlags().BoolVarP(&verbose, "verbose",
"v", false, "Verbose output.")
RootCmd.PersistentPreRun = preConfig
RootCmd.Run = versionInfo
}
开发者ID:romana,项目名称:core,代码行数:28,代码来源:root.go
示例7: init
func init() {
cobra.OnInitialize(initConfig)
RootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.runes.yaml)")
RootCmd.AddCommand(createCmd)
RootCmd.AddCommand(runCmd)
}
开发者ID:adriamb,项目名称:gopad,代码行数:7,代码来源:cmd.go
示例8: init
func init() {
RootCmd.PersistentFlags().Bool(showLibmachineLogs, false, "Whether or not to show logs from libmachine.")
RootCmd.AddCommand(configCmd.ConfigCmd)
pflag.CommandLine.AddGoFlagSet(goflag.CommandLine)
viper.BindPFlags(RootCmd.PersistentFlags())
cobra.OnInitialize(initConfig)
}
开发者ID:rawlingsj,项目名称:gofabric8,代码行数:7,代码来源:root.go
示例9: init
func init() {
cobra.OnInitialize(initConfig)
// Here you will define your flags and configuration settings.
// Cobra supports Persistent Flags, which, if defined here,
// will be global for your application.
RootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.gopixabay.yaml)")
// Cobra also supports local flags, which will only run
// when this action is called directly.
RootCmd.PersistentFlags().StringVarP(&arguments.request.Key, "key", "k", "", "Your pixabay API key")
RootCmd.Flags().StringVarP(&arguments.request.ResponseGroup, "response-group", "g", "image_details", "Select the information returned: image details or URLs of high resolution images. High resolution image URLs and details cannot be obtained in a single request. (image_details, high_resolution)")
RootCmd.Flags().StringVar(&arguments.request.ID, "id", "", "ID, ID hash, or a comma separated list of values for fetching or updating specific images. In a comma separated list, IDs and ID hashs cannot be used together.")
RootCmd.Flags().StringVarP(&arguments.request.Query, "query", "q", "", "A text query to use when searching for images")
RootCmd.Flags().StringVarP(&arguments.request.Lang, "lang", "l", "en", "Language code of the language to be searched in. ")
RootCmd.Flags().StringVarP(&arguments.request.ImageType, "image-type", "t", "all", "A media type to search within. (all, photo, illustration, vector)")
RootCmd.Flags().StringVarP(&arguments.request.Orientation, "orientation", "o", "all", "Whether an image is wider than it is tall, or taller than it is wide. (all, horizontal, vertical)")
RootCmd.Flags().StringVarP(&arguments.request.Category, "category", "c", "", "Filter images by category. (fashion, nature, backgrounds, science, education, people, feelings, religion, health, places, animals, industry, food, computer, sports, transportation, travel, buildings, business, music)")
RootCmd.Flags().IntVar(&arguments.request.MinWidth, "min-width", 0, "Minimum image width. ")
RootCmd.Flags().IntVar(&arguments.request.MinWidth, "min-height", 0, "Minimum image height. ")
RootCmd.Flags().BoolVarP(&arguments.request.EditorsChoice, "editors-choice", "e", false, "Select images that have received an Editor's Choice award. ")
RootCmd.Flags().BoolVarP(&arguments.request.SafeSearch, "safesearch", "s", false, "A flag indicating that only images suitable for all ages should be returned. ")
RootCmd.Flags().StringVarP(&arguments.request.Order, "order", "r", "popular", "How the results should be ordered. (popular, latest)")
RootCmd.Flags().IntVarP(&arguments.request.Page, "page", "p", 1, "Returned search results are paginated. Use this parameter to select the page number. ")
RootCmd.Flags().IntVar(&arguments.request.PerPage, "per-page", 20, "Determine the number of results per page.")
RootCmd.Flags().StringVar(&arguments.request.Callback, "callback", "", "JSONP callback function name")
RootCmd.Flags().BoolVar(&arguments.request.Pretty, "pretty", false, "Prettify and indent JSON output. This option is for development puposes only and should not be used in production. ")
RootCmd.Flags().StringVar(&arguments.size, "size", "og", "Image size to download (og, lg, md, sm, xs) ")
RootCmd.Flags().IntVar(&arguments.simultaneous, "num", 4, "Number of images to download in paralell")
}
开发者ID:netbrain,项目名称:gopixabay,代码行数:32,代码来源:root.go
示例10: init
func init() {
cobra.OnInitialize(initConfig)
RootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.cobra.yaml)")
RootCmd.PersistentFlags().StringVarP(&projectBase, "projectbase", "b", "", "base project directory, e.g. github.com/spf13/")
RootCmd.PersistentFlags().StringP("author", "a", "YOUR NAME", "Author name for copyright attribution")
RootCmd.PersistentFlags().StringVarP(&userLicense, "license", "l", "", "Name of license for the project (can provide `licensetext` in config)")
RootCmd.PersistentFlags().Bool("viper", true, "Use Viper for configuration")
viper.BindPFlag("author", RootCmd.PersistentFlags().Lookup("author"))
viper.BindPFlag("projectbase", RootCmd.PersistentFlags().Lookup("projectbase"))
viper.BindPFlag("useViper", RootCmd.PersistentFlags().Lookup("viper"))
viper.SetDefault("author", "NAME HERE <EMAIL ADDRESS>")
viper.SetDefault("license", "apache")
viper.SetDefault("licenseText", `
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
`)
}
开发者ID:CyCoreSystems,项目名称:coreos-kubernetes,代码行数:25,代码来源:root.go
示例11: init
func init() {
cobra.OnInitialize(initConfig)
// Setting flags here so they can be used by both the root behavior as well as
// by the indidual behaviors of icarus and daedalus
RootCmd.PersistentFlags().StringVar(&CfgFile, "config", "", "config file (default is $CWD/config.yaml)")
RootCmd.PersistentFlags().IntP("port", "p", 8013, "Port run on")
RootCmd.PersistentFlags().IntP("width", "x", 15, "width of the laybrinth")
RootCmd.PersistentFlags().IntP("height", "y", 10, "height of the laybrinth") // 'h' is used for help already
RootCmd.PersistentFlags().IntP("times", "t", 1, "times to solve the laybrinth")
RootCmd.PersistentFlags().IntP("max-steps", "m", 500, "Maximum steps before giving up")
RootCmd.PersistentFlags().BoolP("interactive", "i", false, "runs in interactive mode")
RootCmd.PersistentFlags().BoolP("debug", "d", false, "prints debug messages")
RootCmd.PersistentFlags().Float64P("braid", "b", 1.0, "probability to rearrange an dead end to a braid")
// Bind viper to these flags so viper can read flag values along with config, env, etc.
_ = viper.BindPFlag("width", RootCmd.PersistentFlags().Lookup("width"))
_ = viper.BindPFlag("height", RootCmd.PersistentFlags().Lookup("height"))
_ = viper.BindPFlag("port", RootCmd.PersistentFlags().Lookup("port"))
_ = viper.BindPFlag("times", RootCmd.PersistentFlags().Lookup("times"))
_ = viper.BindPFlag("max-steps", RootCmd.PersistentFlags().Lookup("max-steps"))
_ = viper.BindPFlag("interactive", RootCmd.PersistentFlags().Lookup("interactive"))
_ = viper.BindPFlag("debug", RootCmd.PersistentFlags().Lookup("debug"))
_ = viper.BindPFlag("braid", RootCmd.PersistentFlags().Lookup("braid"))
}
开发者ID:skatsuta,项目名称:labyrinth,代码行数:25,代码来源:labyrinth.go
示例12: init
func init() {
initFlags(cliContext)
cobra.OnInitialize(func() {
cliContext.Addr = net.JoinHostPort(connHost, connPort)
})
}
开发者ID:liugangnhm,项目名称:cockroach,代码行数:7,代码来源:flags.go
示例13: init
func init() {
cobra.OnInitialize(initConfig)
RootCmd.PersistentFlags().StringVar(&cfgFile, "config", "",
"config file path.")
RootCmd.PersistentFlags().BoolVarP(&log.ShowDebug, "debug", "d", false,
"Print debug information")
}
开发者ID:5Sigma,项目名称:Conduit,代码行数:7,代码来源:root.go
示例14: init
func init() {
cobra.OnInitialize(initConfig)
// Here you will define your flags and configuration settings.
// Cobra supports Persistent Flags, which, if defined here,
// will be global for your application.
RootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.nessusControl.yaml)")
// Cobra also supports local flags, which will only run
// when this action is called directly.
RootCmd.PersistentFlags().StringP("username", "u", "admin", "The username to log into Nessus.")
RootCmd.PersistentFlags().StringP("password", "a", "Th1sSh0u1dB3AStr0ngP422w0rd", "The password to use to log into Nessus.")
RootCmd.PersistentFlags().StringP("hostname", "o", "127.0.0.1", "The host where Nessus is located.")
RootCmd.PersistentFlags().StringP("port", "p", "8834", "The port number used to connect to Nessus.")
RootCmd.PersistentFlags().BoolP("debug", "d", false, "Use this flag to enable debug mode")
viper.BindPFlag("auth.username", RootCmd.PersistentFlags().Lookup("username"))
viper.SetDefault("auth.username", "admin")
viper.BindPFlag("auth.password", RootCmd.PersistentFlags().Lookup("password"))
viper.SetDefault("auth.password", "Th1sSh0u1dB3AStr0ngP422w0rd")
viper.BindPFlag("nessusLocation.hostname", RootCmd.PersistentFlags().Lookup("hostname"))
viper.SetDefault("nessusLocation.hostname", "127.0.0.1")
viper.BindPFlag("nessusLocation.port", RootCmd.PersistentFlags().Lookup("port"))
viper.SetDefault("nessusLocation.port", "8834")
viper.BindPFlag("debug", RootCmd.PersistentFlags().Lookup("debug"))
viper.SetDefault("debug", "8834")
}
开发者ID:kkirsche,项目名称:nessusControl,代码行数:27,代码来源:root.go
示例15: init
func init() {
flags := app.PersistentFlags()
flags.BoolVarP(&boolVerbose, "verbose", "V", false, "Print verbose messages")
flags.BoolVarP(&boolDebug, "debug", "D", false, "Print debug messages")
cobra.OnInitialize(Initialize)
}
开发者ID:ailispaw,项目名称:xhyvectl,代码行数:7,代码来源:app.go
示例16: init
func init() {
initFlags(context)
cobra.OnInitialize(func() {
if context.EphemeralSingleNode {
context.Insecure = true
if len(context.JoinUsing) != 0 {
log.Errorf("--join cannot be specified when running a node in dev mode (--dev)")
os.Exit(1)
}
fmt.Printf(`
****
**
** This node is being run in DEVELOPMENT mode.
**
** All data is ephemeral, and there is no security.
**
****
`)
}
context.Addr = net.JoinHostPort(connHost, connPort)
context.PGAddr = net.JoinHostPort(connHost, connPGPort)
})
}
开发者ID:steelglove,项目名称:cockroach,代码行数:25,代码来源:flags.go
示例17: init
func init() {
cobra.OnInitialize(initConfig)
// Here you will define your flags and configuration settings.
// Cobra supports Persistent Flags, which, if defined here,
// will be global for your application.
RootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.gfi.yaml)")
// Get command info.
ci, err = core.GetCmdInfo(os.Args[0])
if err != nil {
log.Fatalln(err)
}
// Output csv path.
csvPath := filepath.Join(ci.Cwd, time.Now().Format("20060102-150405.000")+".csv")
RootCmd.PersistentFlags().StringVarP(&out, "out", "o", csvPath, "Csv output path")
// Verbose flag.
RootCmd.PersistentFlags().BoolVarP(&silent, "silent", "S", false, "Print no count")
// File only flag.
RootCmd.PersistentFlags().BoolVarP(&fileOnly, "file", "f", false, "Get information file only")
// Directory only flag.
RootCmd.PersistentFlags().BoolVarP(&dirOnly, "dir", "d", false, "Get information directory only")
// Whether output csv in ShiftJIS encoding.
RootCmd.PersistentFlags().BoolVarP(&sjisOut, "sjisout", "j", false, "Output csv in ShiftJIS encoding")
// Matches list.
RootCmd.PersistentFlags().StringArrayVarP(&matches, "match", "m", nil, "Match list (Regexp)")
// Ignores list.
RootCmd.PersistentFlags().StringArrayVarP(&ignores, "ignore", "i", nil, "Ignore list (Regexp)")
// log setting.
log.SetFlags(log.Lshortfile)
}
开发者ID:yukimemi,项目名称:gfi,代码行数:33,代码来源:root.go
示例18: init
func init() {
cobra.OnInitialize(initConfig)
// Default configuration can be overrided
RootCmd.PersistentFlags().StringVar(&config.ConfigFile, "config", "", "Config file (default is $HOME/.subify.json). Build a file like this to change default behaviour")
RootCmd.PersistentFlags().BoolVarP(&config.Verbose, "verbose", "v", false, "Print more information while executing")
RootCmd.PersistentFlags().BoolVarP(&config.Dev, "dev", "", false, "Instanciate development sandbox instead of production variables")
}
开发者ID:vincentdaniel,项目名称:subify,代码行数:8,代码来源:root.go
示例19: init
func init() {
cobra.OnInitialize(initConfig)
RootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.stalk/config.yaml)")
RootCmd.PersistentFlags().StringVar(&clearbitKey, "key", "", "ClearBit API key")
RootCmd.Flags().StringP("email", "e", "[email protected]", "Email of the person to find")
}
开发者ID:pzurek,项目名称:stalk,代码行数:8,代码来源:root.go
示例20: init
func init() {
cobra.OnInitialize(initConfig)
RexCmd.PersistentFlags().StringVarP(&CfgFile, "config", "c", "", "config file (default is $HOME/.rex.yml)")
RexCmd.Flags().BoolVarP(&Version, "version", "v", false, "Show rex version")
RexCmd.Flags().SetAnnotation("config", cobra.BashCompFilenameExt, []string{"yaml", "yml"})
}
开发者ID:beanworks,项目名称:rex,代码行数:8,代码来源:rex.go
注:本文中的github.com/spf13/cobra.OnInitialize函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论