INNER CODE UNIT · Go

addCommandMetadata

dropbox/dbxcli · tools/gen-docs/main.go:87

func addCommandMetadata(root *cobra.Command) error {
	return walkCommands(root, func(command *cobra.Command) error {
		path := filepath.Join(outputDir, strings.ReplaceAll(command.CommandPath(), " ", "_")+".md")
		contents, err := os.ReadFile(path)
		if err != nil {
			return fmt.Errorf("read generated doc %s: %w", path, err)
		}

		updated := insertMetadataSection(contents, commandMetadataSection(command))
		if err := os.WriteFile(path, updated, 0o644); err != nil {
			return fmt.Errorf("write generated doc %s: %w", path, err)
		}
		return nil
	})
}

func walkCommands(command *cobra.Command, fn func(*cobra.Command) error) error {
	if !command.IsAvailableCommand() || command.IsAdditionalHelpTopicCommand() {

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…