forked from toolshed/abra
refactor: urfave v3
This commit is contained in:
cli
app
app.gobackup.gocheck.gocmd.goconfig.gocp.godeploy.golist.gologs.gonew.gops.goremove.gorestart.gorestore.gorollback.gorun.gosecret.goservices.goundeploy.goupgrade.govolume.go
catalogue
cli.gointernal
recipe
server
updater
pkg/autocomplete
scripts/autocomplete
vendor
github.com
Azure
go-ansiterm
ProtonMail
go-crypto
openpgp
beorn7
perks
quantile
cenkalti
backoff
containers
image
docker
reference
pkg
types
cpuguy83
go-md2man
v2
davecgh
go-spew
docker
emirpasic
gods
felixge
ghodss
go-git
gcfg
go-billy
go-git
v5
plumbing
format
config
gitignore
idxfile
index
packfile
object
protocol
packp
utils
worktree_bsd.goworktree_js.goworktree_linux.goworktree_unix_other.goworktree_windows.gogogo
protobuf
google
go-cmp
shlex
uuid
hashicorp
go-cleanhttp
kballard
go-shellquote
kevinburke
ssh_config
lucasb-eyer
go-colorful
mattn
go-isatty
mgutz
ansi
miekg
pkcs11
opencontainers
pkg
pmezard
go-difflib
difflib
russross
blackfriday
sergi
sirupsen
logrus
spf13
theupdateframework
notary
urfave
cli
.flake8.gitignoreCODE_OF_CONDUCT.mdLICENSEREADME.mdapp.gocategory.gocli.gocommand.gocontext.godocs.goerrors.gofish.goflag.goflag_bool.goflag_bool_t.goflag_duration.goflag_float64.goflag_generic.goflag_int.goflag_int64.goflag_int64_slice.goflag_int_slice.goflag_string.goflag_string_slice.goflag_uint.goflag_uint64.gofuncs.gohelp.goparse.gotemplate.go
v2
.flake8README.mdapp.goargs.gocli.gocommand.gocontext.godocs.goflag-spec.yamlflag_bool.goflag_duration.goflag_float64.goflag_float64_slice.goflag_generic.goflag_int.goflag_int64.goflag_int64_slice.goflag_int_slice.goflag_path.goflag_string.goflag_string_slice.goflag_timestamp.goflag_uint.goflag_uint64.goflag_uint64_slice.goflag_uint_slice.gogodoc-current.txthelp.gomkdocs-reqs.txtsliceflag.gosort.gosuggestions.gozz_generated.flags.go
v3
.gitignore.golangci.yamlCODE_OF_CONDUCT.mdLICENSEMakefileREADME.mdargs.go
autocomplete
category.gocli.gocommand.gocompletion.goerrors.gofish.goflag.goflag_bool.goflag_bool_with_inverse.goflag_duration.goflag_ext.goflag_float.goflag_float_slice.goflag_impl.goflag_int.goflag_int_slice.goflag_map_impl.goflag_mutex.goflag_slice_base.goflag_string.goflag_string_map.goflag_string_slice.goflag_timestamp.goflag_uint.goflag_uint_slice.gofuncs.gogodoc-current.txthelp.gomkdocs-reqs.txtmkdocs.ymlparse.gosort.gostaticcheck.confsuggestions.gotemplate.govalue_source.goxeipuuv
gojsonschema
xrash
go.opentelemetry.io
proto
otlp
golang.org
x
google.golang.org
protobuf
internal
impl
gopkg.in
warnings.v0
yaml.v2
yaml.v3
gotest.tools
v3
internal
difflib
19
vendor/github.com/spf13/pflag/flag.go
generated
vendored
19
vendor/github.com/spf13/pflag/flag.go
generated
vendored
@ -27,32 +27,23 @@ unaffected.
|
||||
Define flags using flag.String(), Bool(), Int(), etc.
|
||||
|
||||
This declares an integer flag, -flagname, stored in the pointer ip, with type *int.
|
||||
|
||||
var ip = flag.Int("flagname", 1234, "help message for flagname")
|
||||
|
||||
If you like, you can bind the flag to a variable using the Var() functions.
|
||||
|
||||
var flagvar int
|
||||
func init() {
|
||||
flag.IntVar(&flagvar, "flagname", 1234, "help message for flagname")
|
||||
}
|
||||
|
||||
Or you can create custom flags that satisfy the Value interface (with
|
||||
pointer receivers) and couple them to flag parsing by
|
||||
|
||||
flag.Var(&flagVal, "name", "help message for flagname")
|
||||
|
||||
For such flags, the default value is just the initial value of the variable.
|
||||
|
||||
After all flags are defined, call
|
||||
|
||||
flag.Parse()
|
||||
|
||||
to parse the command line into the defined flags.
|
||||
|
||||
Flags may then be used directly. If you're using the flags themselves,
|
||||
they are all pointers; if you bind to variables, they're values.
|
||||
|
||||
fmt.Println("ip has value ", *ip)
|
||||
fmt.Println("flagvar has value ", flagvar)
|
||||
|
||||
@ -63,26 +54,22 @@ The arguments are indexed from 0 through flag.NArg()-1.
|
||||
The pflag package also defines some new functions that are not in flag,
|
||||
that give one-letter shorthands for flags. You can use these by appending
|
||||
'P' to the name of any function that defines a flag.
|
||||
|
||||
var ip = flag.IntP("flagname", "f", 1234, "help message")
|
||||
var flagvar bool
|
||||
func init() {
|
||||
flag.BoolVarP(&flagvar, "boolname", "b", true, "help message")
|
||||
}
|
||||
flag.VarP(&flagval, "varname", "v", "help message")
|
||||
|
||||
Shorthand letters can be used with single dashes on the command line.
|
||||
Boolean shorthand flags can be combined with other shorthand flags.
|
||||
|
||||
Command line flag syntax:
|
||||
|
||||
--flag // boolean flags only
|
||||
--flag=x
|
||||
|
||||
Unlike the flag package, a single dash before an option means something
|
||||
different than a double dash. Single dashes signify a series of shorthand
|
||||
letters for flags. All but the last shorthand letter must be boolean flags.
|
||||
|
||||
// boolean flags
|
||||
-f
|
||||
-abc
|
||||
@ -940,9 +927,9 @@ func (f *FlagSet) usage() {
|
||||
}
|
||||
}
|
||||
|
||||
// --unknown (args will be empty)
|
||||
// --unknown --next-flag ... (args will be --next-flag ...)
|
||||
// --unknown arg ... (args will be arg ...)
|
||||
//--unknown (args will be empty)
|
||||
//--unknown --next-flag ... (args will be --next-flag ...)
|
||||
//--unknown arg ... (args will be arg ...)
|
||||
func stripUnknownFlagValue(args []string) []string {
|
||||
if len(args) == 0 {
|
||||
//--unknown
|
||||
|
28
vendor/github.com/spf13/pflag/string_slice.go
generated
vendored
28
vendor/github.com/spf13/pflag/string_slice.go
generated
vendored
@ -98,12 +98,9 @@ func (f *FlagSet) GetStringSlice(name string) ([]string, error) {
|
||||
// The argument p points to a []string variable in which to store the value of the flag.
|
||||
// Compared to StringArray flags, StringSlice flags take comma-separated value as arguments and split them accordingly.
|
||||
// For example:
|
||||
//
|
||||
// --ss="v1,v2" --ss="v3"
|
||||
//
|
||||
// --ss="v1,v2" --ss="v3"
|
||||
// will result in
|
||||
//
|
||||
// []string{"v1", "v2", "v3"}
|
||||
// []string{"v1", "v2", "v3"}
|
||||
func (f *FlagSet) StringSliceVar(p *[]string, name string, value []string, usage string) {
|
||||
f.VarP(newStringSliceValue(value, p), name, "", usage)
|
||||
}
|
||||
@ -117,12 +114,9 @@ func (f *FlagSet) StringSliceVarP(p *[]string, name, shorthand string, value []s
|
||||
// The argument p points to a []string variable in which to store the value of the flag.
|
||||
// Compared to StringArray flags, StringSlice flags take comma-separated value as arguments and split them accordingly.
|
||||
// For example:
|
||||
//
|
||||
// --ss="v1,v2" --ss="v3"
|
||||
//
|
||||
// --ss="v1,v2" --ss="v3"
|
||||
// will result in
|
||||
//
|
||||
// []string{"v1", "v2", "v3"}
|
||||
// []string{"v1", "v2", "v3"}
|
||||
func StringSliceVar(p *[]string, name string, value []string, usage string) {
|
||||
CommandLine.VarP(newStringSliceValue(value, p), name, "", usage)
|
||||
}
|
||||
@ -136,12 +130,9 @@ func StringSliceVarP(p *[]string, name, shorthand string, value []string, usage
|
||||
// The return value is the address of a []string variable that stores the value of the flag.
|
||||
// Compared to StringArray flags, StringSlice flags take comma-separated value as arguments and split them accordingly.
|
||||
// For example:
|
||||
//
|
||||
// --ss="v1,v2" --ss="v3"
|
||||
//
|
||||
// --ss="v1,v2" --ss="v3"
|
||||
// will result in
|
||||
//
|
||||
// []string{"v1", "v2", "v3"}
|
||||
// []string{"v1", "v2", "v3"}
|
||||
func (f *FlagSet) StringSlice(name string, value []string, usage string) *[]string {
|
||||
p := []string{}
|
||||
f.StringSliceVarP(&p, name, "", value, usage)
|
||||
@ -159,12 +150,9 @@ func (f *FlagSet) StringSliceP(name, shorthand string, value []string, usage str
|
||||
// The return value is the address of a []string variable that stores the value of the flag.
|
||||
// Compared to StringArray flags, StringSlice flags take comma-separated value as arguments and split them accordingly.
|
||||
// For example:
|
||||
//
|
||||
// --ss="v1,v2" --ss="v3"
|
||||
//
|
||||
// --ss="v1,v2" --ss="v3"
|
||||
// will result in
|
||||
//
|
||||
// []string{"v1", "v2", "v3"}
|
||||
// []string{"v1", "v2", "v3"}
|
||||
func StringSlice(name string, value []string, usage string) *[]string {
|
||||
return CommandLine.StringSliceP(name, "", value, usage)
|
||||
}
|
||||
|
Reference in New Issue
Block a user