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

Function addCommandMetadata

tools/gen-docs/main.go:87–101  ·  view source on GitHub ↗
(root *cobra.Command)

Source from the content-addressed store, hash-verified

85}
86
87func addCommandMetadata(root *cobra.Command) error {
88 return walkCommands(root, func(command *cobra.Command) error {
89 path := filepath.Join(outputDir, strings.ReplaceAll(command.CommandPath(), " ", "_")+".md")
90 contents, err := os.ReadFile(path)
91 if err != nil {
92 return fmt.Errorf("read generated doc %s: %w", path, err)
93 }
94
95 updated := insertMetadataSection(contents, commandMetadataSection(command))
96 if err := os.WriteFile(path, updated, 0o644); err != nil {
97 return fmt.Errorf("write generated doc %s: %w", path, err)
98 }
99 return nil
100 })
101}
102
103func walkCommands(command *cobra.Command, fn func(*cobra.Command) error) error {
104 if !command.IsAvailableCommand() || command.IsAdditionalHelpTopicCommand() {

Callers 1

runFunction · 0.85

Calls 3

walkCommandsFunction · 0.85
insertMetadataSectionFunction · 0.85
commandMetadataSectionFunction · 0.85

Tested by

no test coverage detected