Remove reflect calls for doc generation

This commit is contained in:
Naveen Gogineni
2021-03-27 13:07:49 -04:00
parent e79ceb69ff
commit 50c71ed517
16 changed files with 234 additions and 47 deletions

View File

@@ -1,6 +1,9 @@
package cli
import "flag"
import (
"flag"
"fmt"
)
// StringFlag is a flag with type string
type StringFlag struct {
@@ -60,6 +63,22 @@ func (f *StringFlag) IsVisible() bool {
return !f.Hidden
}
// GetDefaultText returns the default text for this flag
func (f *StringFlag) GetDefaultText() string {
if f.DefaultText != "" {
return f.DefaultText
}
if f.Value == "" {
return f.Value
}
return fmt.Sprintf("%q", f.Value)
}
// GetEnvVars returns the env vars for this flag
func (f *StringFlag) GetEnvVars() []string {
return f.EnvVars
}
// Apply populates the flag given the flag set and environment
func (f *StringFlag) Apply(set *flag.FlagSet) error {
if val, ok := flagFromEnvOrFile(f.EnvVars, f.FilePath); ok {