MCPcopy Create free account
hub / github.com/dolthub/doltgresql / PrintDefaults

Function PrintDefaults

cmd/doltgres/main.go:111–151  ·  view source on GitHub ↗

PrintDefaults is modified from the flag package to control the order of printing

(fs *flag.FlagSet)

Source from the content-addressed store, hash-verified

109
110// PrintDefaults is modified from the flag package to control the order of printing
111func PrintDefaults(fs *flag.FlagSet) {
112 helpOrder := []string{
113 configParam,
114 dataDirParam,
115 configHelpFlag,
116 versionFlag,
117 chdirParam,
118 stdInParam,
119 stdOutParam,
120 stdErrParam,
121 stdOutAndErrParam,
122 }
123
124 for _, fName := range helpOrder {
125 f := fs.Lookup(fName)
126 var b strings.Builder
127 fmt.Fprintf(&b, " -%s", f.Name) // Two spaces before -; see next two comments.
128 name, usage := flag.UnquoteUsage(f)
129 if len(name) > 0 {
130 b.WriteString(" ")
131 b.WriteString(name)
132 }
133 // Boolean flags of one ASCII letter are so common we
134 // treat them specially, putting their usage on the same line.
135 if b.Len() <= 4 { // space, space, '-', 'x'.
136 b.WriteString("\t")
137 } else {
138 // Four spaces before the tab triggers good alignment
139 // for both 4- and 8-space tab stops.
140 b.WriteString("\n \t")
141 }
142 // wrap at 80 chars
143 usage = wordwrap.WrapString(usage, 76)
144 b.WriteString(strings.ReplaceAll(usage, "\n", "\n \t"))
145
146 if f.DefValue != "false" && f.DefValue != "" {
147 fmt.Fprintf(&b, " (default %v)", f.DefValue)
148 }
149 fmt.Fprint(fs.Output(), b.String(), "\n")
150 }
151}
152
153func main() {
154 args := os.Args[1:]

Callers 1

parseArgsFunction · 0.85

Calls 4

WriteStringMethod · 0.80
LookupMethod · 0.65
LenMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected