MCPcopy Create free account
hub / github.com/dropbox/dbxcli / commandMetadataSection

Function commandMetadataSection

tools/gen-docs/main.go:138–238  ·  view source on GitHub ↗
(command *cobra.Command)

Source from the content-addressed store, hash-verified

136}
137
138func commandMetadataSection(command *cobra.Command) []byte {
139 manifest := cmd.CommandManifestFor(command)
140 var buf bytes.Buffer
141 buf.WriteString("### Command metadata\n\n")
142 fmt.Fprintf(&buf, "* Structured JSON output: %s\n", yesNo(manifest.SupportsStructuredOutput))
143 buf.WriteString("* JSON help manifest: yes\n")
144 buf.WriteString("* Manifest version: `" + manifest.ManifestVersion + "`\n")
145 buf.WriteString("* Auth modes: " + markdownValueList(manifest.AuthModes) + "\n")
146 buf.WriteString("* Dropbox scopes: " + markdownValueList(manifest.DropboxScopes) + "\n")
147
148 if aliases := sortedAliases(command); len(aliases) > 0 {
149 buf.WriteString("* Aliases: ")
150 for i, alias := range aliases {
151 if i > 0 {
152 buf.WriteString(", ")
153 }
154 buf.WriteString("`" + alias + "`")
155 }
156 buf.WriteString("\n")
157 }
158
159 if len(manifest.Args) > 0 {
160 buf.WriteString("* Arguments: ")
161 for i, arg := range manifest.Args {
162 if i > 0 {
163 buf.WriteString(", ")
164 }
165 requirement := "optional"
166 if arg.Required {
167 requirement = "required"
168 }
169 variadic := ""
170 if arg.Variadic {
171 variadic = ", variadic"
172 }
173 streamDash := ""
174 if arg.StreamDash {
175 streamDash = ", `-` stream operand"
176 }
177 enumValues := ""
178 if len(arg.EnumValues) > 0 {
179 enumValues = "; values: " + markdownValueList(arg.EnumValues)
180 }
181 fmt.Fprintf(&buf, "`%s` (%s, %s%s%s%s)", arg.Name, requirement, arg.ValueKind, variadic, streamDash, enumValues)
182 }
183 buf.WriteString("\n")
184 }
185
186 if len(manifest.Flags) > 0 {
187 var describedFlags []string
188 for _, flag := range manifest.Flags {
189 var details []string
190 if len(flag.EnumValues) > 0 {
191 details = append(details, "values: "+markdownValueList(flag.EnumValues))
192 }
193 if len(flag.Conflicts) > 0 {
194 details = append(details, "conflicts: "+markdownValueList(flag.Conflicts))
195 }

Callers 1

addCommandMetadataFunction · 0.85

Calls 5

CommandManifestForFunction · 0.92
yesNoFunction · 0.85
markdownValueListFunction · 0.85
sortedAliasesFunction · 0.85
relativeCommandPathFunction · 0.85

Tested by

no test coverage detected