Add markdown and man page docs generation methods
This adds two new methods to the `App` struct: - `ToMarkdown`: creates a markdown documentation string - `ToMan`: creates a man page string Signed-off-by: Sascha Grunert <mail@saschagrunert.de>
This commit is contained in:
committed by
Sascha Grunert
parent
97179ca390
commit
40d4a25a01
@@ -4,6 +4,7 @@ package {{ .PackageName }}
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
@@ -40,6 +41,22 @@ func (f {{ $flag.Name }}Flag) IsRequired() bool {
|
||||
return f.Required
|
||||
}
|
||||
|
||||
// TakesValue returns true of the flag takes a value, otherwise false
|
||||
func (f {{ $flag.Name }}Flag) TakesValue() bool {
|
||||
return {{ $flag.Value }}
|
||||
}
|
||||
|
||||
// GetUsage returns the usage string for the flag
|
||||
func (f {{ $flag.Name }}Flag) GetUsage() string {
|
||||
return f.Usage
|
||||
}
|
||||
|
||||
// GetValue returns the flags value as string representation and an empty
|
||||
// string if the flag takes no value at all.
|
||||
func (f {{ $flag.Name }}Flag) GetValue() string {
|
||||
{{ $flag.ValueString }}
|
||||
}
|
||||
|
||||
// {{ $flag.Name }} looks up the value of a local {{ $flag.Name }}Flag, returns
|
||||
// {{ $flag.ContextDefault }} if not found
|
||||
func (c *Context) {{ $flag.Name }}(name string) {{ if ne .ContextType "" }}{{ $flag.ContextType }}{{ else }}{{ $flag.Type }}{{- end }} {
|
||||
@@ -66,4 +83,4 @@ func lookup{{ $flag.Name }}(name string, set *flag.FlagSet) {{ if ne .ContextTyp
|
||||
}
|
||||
return {{ $flag.ContextDefault }}
|
||||
}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
Reference in New Issue
Block a user