本文整理汇总了Golang中github.com/spf13/pflag.FlagSet.StringSliceVarP方法的典型用法代码示例。如果您正苦于以下问题:Golang FlagSet.StringSliceVarP方法的具体用法?Golang FlagSet.StringSliceVarP怎么用?Golang FlagSet.StringSliceVarP使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/spf13/pflag.FlagSet
的用法示例。
在下文中一共展示了FlagSet.StringSliceVarP方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: AddFlags
func (g *GeneratorArgs) AddFlags(fs *pflag.FlagSet) {
fs.StringSliceVarP(&g.InputDirs, "input-dirs", "i", g.InputDirs, "Comma-separated list of import paths to get input types from.")
fs.StringVarP(&g.OutputBase, "output-base", "o", g.OutputBase, "Output base; defaults to $GOPATH/src/ or ./ if $GOPATH is not set.")
fs.StringVarP(&g.OutputPackagePath, "output-package", "p", g.OutputPackagePath, "Base package path.")
fs.StringVarP(&g.GoHeaderFilePath, "go-header-file", "h", g.GoHeaderFilePath, "File containing boilerplate header text. The string YEAR will be replaced with the current 4-digit year.")
fs.BoolVar(&g.VerifyOnly, "verify-only", g.VerifyOnly, "If true, only verify existing output, do not write anything.")
}
示例2: flags
func flags(set *pflag.FlagSet) {
// Unused cli args
set.StringVarP(&buildDir, "build", "b", "",
"Path to target directory to place generated CSS, relative paths inside project directory are preserved")
set.BoolVarP(&comments, "comment", "", false, "Turn on source comments")
set.BoolVar(&debug, "debug", false, "Show detailed debug information")
var nothingb bool
set.BoolVar(&debug, "debug-info", false, "")
set.MarkDeprecated("debug-info", "Use --debug instead")
set.StringVarP(&dir, "dir", "d", "",
"Path to locate images for spriting and image functions")
set.StringVar(&dir, "images-dir", "", "")
set.MarkDeprecated("images-dir", "Use -d instead")
set.StringVar(&font, "font", ".", "Path to directory containing fonts")
set.StringVar(&gen, "generated-images-path", "", "")
set.MarkDeprecated("generated-images-path", "Use --gen instead")
set.StringVar(&gen, "gen", ".", "Path to place generated images")
set.StringVarP(&proj, "proj", "p", "",
"Path to directory containing Sass stylesheets")
set.BoolVar(¬hingb, "no-line-comments", false, "UNSUPPORTED: Disable line comments, use comments")
set.MarkDeprecated("no-line-comments", "Use --comments instead")
set.BoolVar(&relativeAssets, "relative-assets", false, "UNSUPPORTED: Make compass asset helpers generate relative urls to assets.")
set.BoolVar(&sourceMap, "source-map", false, "Enable emitting of source maps, must specify build directory to use this")
set.BoolVarP(&showVersion, "version", "v", false, "Show the app version")
set.StringVar(&cachebust, "cachebust", "", "Defeat cache by appending timestamps to static assets ie. ts, sum, timestamp")
set.StringVarP(&style, "style", "s", "nested",
`nested style of output CSS
available options: nested, expanded, compact, compressed`)
set.StringVar(&style, "output-style", "nested", "")
set.MarkDeprecated("output-style", "Use --style instead")
set.BoolVar(&timeB, "time", false, "Retrieve timing information")
var nothing string
set.StringVar(¬hing, "require", "", "")
set.MarkDeprecated("require", "Compass backwards compat, Not supported")
set.MarkDeprecated("require", "Not supported")
set.StringVar(¬hing, "environment", "", "")
set.MarkDeprecated("environment", "Not supported")
set.StringSliceVar(&includes, "includes", nil, "Include Sass from additional directories")
set.StringSliceVarP(&includes, "", "I", nil, "")
set.MarkDeprecated("I", "Compass backwards compat, use --includes instead")
set.StringVar(&buildDir, "css-dir", "",
"Compass backwards compat. Reference locations relative to Sass project directory")
set.MarkDeprecated("css-dir", "Use -b instead")
set.StringVar(&jsDir, "javascripts-dir", "", "")
set.MarkDeprecated("javascripts-dir", "Compass backwards compat, ignored")
set.StringSliceVar(&includes, "sass-dir", nil,
"Compass backwards compat, use --includes instead")
set.StringVarP(&config, "config", "c", "",
"Temporarily disabled: Location of the config file")
set.StringVar(&cpuprofile, "cpuprofile", "", "Go runtime cpu profilling for debugging")
}
示例3: AddFlags
func (g *GeneratorArgs) AddFlags(fs *pflag.FlagSet) {
fs.StringSliceVarP(&g.InputDirs, "input-dirs", "i", g.InputDirs, "Comma-separated list of import paths to get input types from.")
fs.StringVarP(&g.OutputBase, "output-base", "o", g.OutputBase, "Output base; defaults to $GOPATH/src/ or ./ if $GOPATH is not set.")
fs.StringVarP(&g.OutputPackagePath, "output-package", "p", g.OutputPackagePath, "Base package path.")
fs.StringVarP(&g.OutputFileBaseName, "output-file-base", "O", g.OutputFileBaseName, "Base name (without .go suffix) for output files.")
fs.StringVarP(&g.GoHeaderFilePath, "go-header-file", "h", g.GoHeaderFilePath, "File containing boilerplate header text. The string YEAR will be replaced with the current 4-digit year.")
fs.BoolVar(&g.VerifyOnly, "verify-only", g.VerifyOnly, "If true, only verify existing output, do not write anything.")
fs.StringVar(&g.GeneratedBuildTag, "build-tag", g.GeneratedBuildTag, "A Go build tag to use to identify files generated by this command. Should be unique.")
}
示例4: initDeploymentFlags
func initDeploymentFlags(fs *pflag.FlagSet, f *fg.Flags) {
fs.StringVarP(&f.JobPath, "job", "j", defaultJobPath, "filename of the job description")
fs.StringVarP(&f.ClusterPath, "cluster", "c", defaultClusterPath, "cluster description name or filename")
fs.StringVarP(&f.TunnelOverride, "tunnel", "t", defaultTunnelOverride, "SSH endpoint to tunnel through with fleet (cluster override)")
fs.StringSliceVarP(&f.Groups, "groups", "g", defaultGroups, "target task groups to deploy")
fs.BoolVarP(&f.Force, "force", "f", defaultForce, "wheather to confirm destroy or not")
fs.BoolVarP(&f.AutoContinue, "yes", "y", false, "auto continue on confirmation")
fs.BoolVarP(&f.DryRun, "dry-run", "d", defaultDryRun, "wheather to schedule units or not")
fs.UintVar(&f.ScalingGroup, "scaling-group", defaultScalingGroup, "scaling group to deploy")
fs.BoolVarP(&f.Local, "local", "l", defaultLocal, "User local vagrant test cluster")
fs.DurationVar(&f.StopDelay, "stop-delay", defaultStopDelay, "Time between stop and destroy")
fs.DurationVar(&f.DestroyDelay, "destroy-delay", defaultDestroyDelay, "Time between destroy and re-create")
fs.DurationVar(&f.SliceDelay, "slice-delay", defaultSliceDelay, "Time between update of scaling slices")
fs.VarP(&f.Options, "option", "o", "Set an option (key=value)")
f.VaultCACert = os.Getenv("VAULT_CACERT")
f.VaultCAPath = os.Getenv("VAULT_CAPATH")
fs.StringVar(&f.VaultAddr, "vault-addr", "", "URL of the vault (defaults to VAULT_ADDR environment variable)")
fs.StringVar(&f.VaultCACert, "vault-cacert", f.VaultCACert, "Path to a PEM-encoded CA cert file to use to verify the Vault server SSL certificate")
fs.StringVar(&f.VaultCAPath, "vault-capath", f.VaultCAPath, "Path to a directory of PEM-encoded CA cert files to verify the Vault server SSL certificate")
fs.StringVarP(&f.GithubToken, "github-token", "G", "", "Personal github token for secret logins")
fs.StringVar(&f.GithubTokenPath, "github-token-path", defaultGithubTokenPath, "Path of a file containing your github token")
}
示例5: BindListFlag
// BindListFlag binds a flag that expects a kube list value. Note that if the target
// comes pre-populated, that list is not erased; anything the user puts in the flag
// is added on. This is probably a bug in k8s impl of StringList.
func (i FlagInfo) BindListFlag(flags *pflag.FlagSet, target *[]string) {
// assume flags with no longname are not desired
if len(i.LongName) > 0 {
flags.StringSliceVarP(target, i.LongName, i.ShortName, *target, i.Description)
}
}
示例6: execTags
//.........这里部分代码省略.........
}
} else {
valField.SetString(value)
}
case reflect.Bool:
v := value == "true"
if typeField.Tag.Get("flag") != "" {
if len(parts) == 1 {
fs.BoolVar(valField.Addr().Interface().(*bool), parts[0], v, typeField.Tag.Get("description"))
} else {
fs.BoolVarP(valField.Addr().Interface().(*bool), parts[0], parts[1], v, typeField.Tag.Get("description"))
}
} else {
valField.SetBool(v)
}
case reflect.Int, reflect.Int8, reflect.Int32, reflect.Int64:
vt, err := strconv.ParseInt(value, 10, 64)
if err != nil {
if value == "" {
vt = 0
} else {
return err
}
}
if typeField.Tag.Get("flag") != "" {
registerFlagInt(typeField.Type.Kind(), fs, valField.Addr().Interface(), parts, vt, typeField.Tag.Get("description"))
} else {
valField.SetInt(vt)
}
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
vt, err := strconv.ParseUint(value, 10, 64)
if err != nil {
if value == "" {
vt = 0
} else {
return err
}
}
if typeField.Tag.Get("flag") != "" {
registerFlagUint(typeField.Type.Kind(), fs, valField.Addr().Interface(), parts, vt, typeField.Tag.Get("description"))
} else {
valField.SetUint(vt)
}
case reflect.Float32, reflect.Float64:
vt, err := strconv.ParseFloat(value, 64)
if err != nil {
if value == "" {
vt = 0.0
} else {
return err
}
}
if typeField.Tag.Get("flag") != "" {
registerFlagFloat(typeField.Type.Kind(), fs, valField.Addr().Interface(), parts, vt, typeField.Tag.Get("description"))
} else {
valField.SetFloat(vt)
}
case reflect.Struct:
if err := execTags(valField.Addr().Interface(), fs); err != nil {
return err
}
case reflect.Slice:
switch typeField.Type.Elem().Kind() {
case reflect.Int:
def := []int{}
for _, v := range strings.Split(value, ",") {
it, err := strconv.ParseInt(strings.TrimSpace(v), 10, 64)
if err != nil {
return err
}
def = append(def, int(it))
}
if len(parts) == 1 {
fs.IntSliceVar(valField.Addr().Interface().(*[]int), parts[0], def, typeField.Tag.Get("description"))
} else {
fs.IntSliceVarP(valField.Addr().Interface().(*[]int), parts[0], parts[1], def, typeField.Tag.Get("description"))
}
case reflect.String:
del := typeField.Tag.Get("delimiter")
if len(del) == 0 {
del = ","
}
def := strings.Split(value, del)
if len(parts) == 1 {
fs.StringSliceVar(valField.Addr().Interface().(*[]string), parts[0], def, typeField.Tag.Get("description"))
} else {
fs.StringSliceVarP(valField.Addr().Interface().(*[]string), parts[0], parts[1], def, typeField.Tag.Get("description"))
}
}
}
}
return nil
}
示例7: stringSliceVarP
func (c *Config) stringSliceVarP(fset *flag.FlagSet, name string, aof *[]string) *flag.Flag {
i := keys[name]
fset.StringSliceVarP(
aof, name, i.Shorthand, c.Viper.GetStringSlice(name), i.Description)
return fset.Lookup(name)
}