|
|
@ -4,6 +4,7 @@ import (
|
|
|
|
"flag"
|
|
|
|
"flag"
|
|
|
|
"fmt"
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"reflect"
|
|
|
|
"runtime"
|
|
|
|
"runtime"
|
|
|
|
"strconv"
|
|
|
|
"strconv"
|
|
|
|
"strings"
|
|
|
|
"strings"
|
|
|
@ -12,7 +13,8 @@ import (
|
|
|
|
|
|
|
|
|
|
|
|
// This flag enables bash-completion for all commands and subcommands
|
|
|
|
// This flag enables bash-completion for all commands and subcommands
|
|
|
|
var BashCompletionFlag = BoolFlag{
|
|
|
|
var BashCompletionFlag = BoolFlag{
|
|
|
|
Name: "generate-bash-completion",
|
|
|
|
Name: "generate-bash-completion",
|
|
|
|
|
|
|
|
Hidden: true,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// This flag prints the version for the application
|
|
|
|
// This flag prints the version for the application
|
|
|
@ -68,6 +70,7 @@ type GenericFlag struct {
|
|
|
|
Value Generic
|
|
|
|
Value Generic
|
|
|
|
Usage string
|
|
|
|
Usage string
|
|
|
|
EnvVar string
|
|
|
|
EnvVar string
|
|
|
|
|
|
|
|
Hidden bool
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// String returns the string representation of the generic flag to display the
|
|
|
|
// String returns the string representation of the generic flag to display the
|
|
|
@ -138,6 +141,7 @@ type StringSliceFlag struct {
|
|
|
|
Value *StringSlice
|
|
|
|
Value *StringSlice
|
|
|
|
Usage string
|
|
|
|
Usage string
|
|
|
|
EnvVar string
|
|
|
|
EnvVar string
|
|
|
|
|
|
|
|
Hidden bool
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// String returns the usage
|
|
|
|
// String returns the usage
|
|
|
@ -208,6 +212,7 @@ type IntSliceFlag struct {
|
|
|
|
Value *IntSlice
|
|
|
|
Value *IntSlice
|
|
|
|
Usage string
|
|
|
|
Usage string
|
|
|
|
EnvVar string
|
|
|
|
EnvVar string
|
|
|
|
|
|
|
|
Hidden bool
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// String returns the usage
|
|
|
|
// String returns the usage
|
|
|
@ -256,6 +261,7 @@ type BoolFlag struct {
|
|
|
|
Usage string
|
|
|
|
Usage string
|
|
|
|
EnvVar string
|
|
|
|
EnvVar string
|
|
|
|
Destination *bool
|
|
|
|
Destination *bool
|
|
|
|
|
|
|
|
Hidden bool
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// String returns a readable representation of this value (for usage defaults)
|
|
|
|
// String returns a readable representation of this value (for usage defaults)
|
|
|
@ -300,6 +306,7 @@ type BoolTFlag struct {
|
|
|
|
Usage string
|
|
|
|
Usage string
|
|
|
|
EnvVar string
|
|
|
|
EnvVar string
|
|
|
|
Destination *bool
|
|
|
|
Destination *bool
|
|
|
|
|
|
|
|
Hidden bool
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// String returns a readable representation of this value (for usage defaults)
|
|
|
|
// String returns a readable representation of this value (for usage defaults)
|
|
|
@ -344,6 +351,7 @@ type StringFlag struct {
|
|
|
|
Usage string
|
|
|
|
Usage string
|
|
|
|
EnvVar string
|
|
|
|
EnvVar string
|
|
|
|
Destination *string
|
|
|
|
Destination *string
|
|
|
|
|
|
|
|
Hidden bool
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// String returns the usage
|
|
|
|
// String returns the usage
|
|
|
@ -393,6 +401,7 @@ type IntFlag struct {
|
|
|
|
Usage string
|
|
|
|
Usage string
|
|
|
|
EnvVar string
|
|
|
|
EnvVar string
|
|
|
|
Destination *int
|
|
|
|
Destination *int
|
|
|
|
|
|
|
|
Hidden bool
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// String returns the usage
|
|
|
|
// String returns the usage
|
|
|
@ -437,6 +446,7 @@ type DurationFlag struct {
|
|
|
|
Usage string
|
|
|
|
Usage string
|
|
|
|
EnvVar string
|
|
|
|
EnvVar string
|
|
|
|
Destination *time.Duration
|
|
|
|
Destination *time.Duration
|
|
|
|
|
|
|
|
Hidden bool
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// String returns a readable representation of this value (for usage defaults)
|
|
|
|
// String returns a readable representation of this value (for usage defaults)
|
|
|
@ -481,6 +491,7 @@ type Float64Flag struct {
|
|
|
|
Usage string
|
|
|
|
Usage string
|
|
|
|
EnvVar string
|
|
|
|
EnvVar string
|
|
|
|
Destination *float64
|
|
|
|
Destination *float64
|
|
|
|
|
|
|
|
Hidden bool
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// String returns the usage
|
|
|
|
// String returns the usage
|
|
|
@ -516,6 +527,16 @@ func (f Float64Flag) GetName() string {
|
|
|
|
return f.Name
|
|
|
|
return f.Name
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func visibleFlags(fl []Flag) []Flag {
|
|
|
|
|
|
|
|
visible := []Flag{}
|
|
|
|
|
|
|
|
for _, flag := range fl {
|
|
|
|
|
|
|
|
if !reflect.ValueOf(flag).FieldByName("Hidden").Bool() {
|
|
|
|
|
|
|
|
visible = append(visible, flag)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return visible
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func prefixFor(name string) (prefix string) {
|
|
|
|
func prefixFor(name string) (prefix string) {
|
|
|
|
if len(name) == 1 {
|
|
|
|
if len(name) == 1 {
|
|
|
|
prefix = "-"
|
|
|
|
prefix = "-"
|
|
|
|