Rebase
This commit is contained in:
parent
fdcbf28476
commit
0764ca2295
23
flag.go
23
flag.go
@ -7,7 +7,6 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"regexp"
|
"regexp"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
@ -303,28 +302,6 @@ func stringifyFlag(f Flag) string {
|
|||||||
fmt.Sprintf("%s\t%s", prefixedNames(f.Names(), placeholder), usageWithDefault))
|
fmt.Sprintf("%s\t%s", prefixedNames(f.Names(), placeholder), usageWithDefault))
|
||||||
}
|
}
|
||||||
|
|
||||||
func stringifyUintSliceFlag(f *UintSliceFlag) string {
|
|
||||||
var defaultVals []string
|
|
||||||
if f.Value != nil && len(f.Value.Value()) > 0 {
|
|
||||||
for _, i := range f.Value.Value() {
|
|
||||||
defaultVals = append(defaultVals, strconv.FormatUint(uint64(i), 10))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return stringifySliceFlag(f.Usage, f.Names(), defaultVals)
|
|
||||||
}
|
|
||||||
|
|
||||||
func stringifyUint64SliceFlag(f *Uint64SliceFlag) string {
|
|
||||||
var defaultVals []string
|
|
||||||
if f.Value != nil && len(f.Value.Value()) > 0 {
|
|
||||||
for _, i := range f.Value.Value() {
|
|
||||||
defaultVals = append(defaultVals, strconv.FormatUint(i, 10))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return stringifySliceFlag(f.Usage, f.Names(), defaultVals)
|
|
||||||
}
|
|
||||||
|
|
||||||
func stringifySliceFlag(usage string, names, defaultVals []string) string {
|
func stringifySliceFlag(usage string, names, defaultVals []string) string {
|
||||||
placeholder, usage := unquoteUsage(usage)
|
placeholder, usage := unquoteUsage(usage)
|
||||||
if placeholder == "" {
|
if placeholder == "" {
|
||||||
|
@ -497,6 +497,86 @@ func (f *TimestampFlag) GetDefaultText() string {
|
|||||||
return f.GetValue()
|
return f.GetValue()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Uint64SliceFlag is a flag with type *Uint64Slice
|
||||||
|
type Uint64SliceFlag struct {
|
||||||
|
Name string
|
||||||
|
|
||||||
|
Category string
|
||||||
|
DefaultText string
|
||||||
|
FilePath string
|
||||||
|
Usage string
|
||||||
|
|
||||||
|
Required bool
|
||||||
|
Hidden bool
|
||||||
|
HasBeenSet bool
|
||||||
|
|
||||||
|
Value *Uint64Slice
|
||||||
|
Destination *Uint64Slice
|
||||||
|
|
||||||
|
Aliases []string
|
||||||
|
EnvVars []string
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsSet returns whether or not the flag has been set through env or file
|
||||||
|
func (f *Uint64SliceFlag) IsSet() bool {
|
||||||
|
return f.HasBeenSet
|
||||||
|
}
|
||||||
|
|
||||||
|
// Names returns the names of the flag
|
||||||
|
func (f *Uint64SliceFlag) Names() []string {
|
||||||
|
return FlagNames(f.Name, f.Aliases)
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsRequired returns whether or not the flag is required
|
||||||
|
func (f *Uint64SliceFlag) IsRequired() bool {
|
||||||
|
return f.Required
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsVisible returns true if the flag is not hidden, otherwise false
|
||||||
|
func (f *Uint64SliceFlag) IsVisible() bool {
|
||||||
|
return !f.Hidden
|
||||||
|
}
|
||||||
|
|
||||||
|
// UintSliceFlag is a flag with type *UintSlice
|
||||||
|
type UintSliceFlag struct {
|
||||||
|
Name string
|
||||||
|
|
||||||
|
Category string
|
||||||
|
DefaultText string
|
||||||
|
FilePath string
|
||||||
|
Usage string
|
||||||
|
|
||||||
|
Required bool
|
||||||
|
Hidden bool
|
||||||
|
HasBeenSet bool
|
||||||
|
|
||||||
|
Value *UintSlice
|
||||||
|
Destination *UintSlice
|
||||||
|
|
||||||
|
Aliases []string
|
||||||
|
EnvVars []string
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsSet returns whether or not the flag has been set through env or file
|
||||||
|
func (f *UintSliceFlag) IsSet() bool {
|
||||||
|
return f.HasBeenSet
|
||||||
|
}
|
||||||
|
|
||||||
|
// Names returns the names of the flag
|
||||||
|
func (f *UintSliceFlag) Names() []string {
|
||||||
|
return FlagNames(f.Name, f.Aliases)
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsRequired returns whether or not the flag is required
|
||||||
|
func (f *UintSliceFlag) IsRequired() bool {
|
||||||
|
return f.Required
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsVisible returns true if the flag is not hidden, otherwise false
|
||||||
|
func (f *UintSliceFlag) IsVisible() bool {
|
||||||
|
return !f.Hidden
|
||||||
|
}
|
||||||
|
|
||||||
// BoolFlag is a flag with type bool
|
// BoolFlag is a flag with type bool
|
||||||
type BoolFlag struct {
|
type BoolFlag struct {
|
||||||
Name string
|
Name string
|
||||||
|
@ -160,6 +160,44 @@ func TestTimestampFlag_SatisfiesFmtStringerInterface(t *testing.T) {
|
|||||||
_ = f.String()
|
_ = f.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestUint64SliceFlag_SatisfiesFlagInterface(t *testing.T) {
|
||||||
|
var f cli.Flag = &cli.Uint64SliceFlag{}
|
||||||
|
|
||||||
|
_ = f.IsSet()
|
||||||
|
_ = f.Names()
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestUint64SliceFlag_SatisfiesRequiredFlagInterface(t *testing.T) {
|
||||||
|
var f cli.RequiredFlag = &cli.Uint64SliceFlag{}
|
||||||
|
|
||||||
|
_ = f.IsRequired()
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestUint64SliceFlag_SatisfiesVisibleFlagInterface(t *testing.T) {
|
||||||
|
var f cli.VisibleFlag = &cli.Uint64SliceFlag{}
|
||||||
|
|
||||||
|
_ = f.IsVisible()
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestUintSliceFlag_SatisfiesFlagInterface(t *testing.T) {
|
||||||
|
var f cli.Flag = &cli.UintSliceFlag{}
|
||||||
|
|
||||||
|
_ = f.IsSet()
|
||||||
|
_ = f.Names()
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestUintSliceFlag_SatisfiesRequiredFlagInterface(t *testing.T) {
|
||||||
|
var f cli.RequiredFlag = &cli.UintSliceFlag{}
|
||||||
|
|
||||||
|
_ = f.IsRequired()
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestUintSliceFlag_SatisfiesVisibleFlagInterface(t *testing.T) {
|
||||||
|
var f cli.VisibleFlag = &cli.UintSliceFlag{}
|
||||||
|
|
||||||
|
_ = f.IsVisible()
|
||||||
|
}
|
||||||
|
|
||||||
func TestBoolFlag_SatisfiesFlagInterface(t *testing.T) {
|
func TestBoolFlag_SatisfiesFlagInterface(t *testing.T) {
|
||||||
var f cli.Flag = &cli.BoolFlag{}
|
var f cli.Flag = &cli.BoolFlag{}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user