From bdbe2318159d77fe42adb82135130338323c85a3 Mon Sep 17 00:00:00 2001 From: Ben Blattberg Date: Thu, 26 Oct 2023 11:57:11 -0500 Subject: [PATCH] Add comments --- Makefile | 3 +++ internal/cmd/pgo.go | 2 ++ 2 files changed, 5 insertions(+) diff --git a/Makefile b/Makefile index 99c1a664..5a4f3c83 100644 --- a/Makefile +++ b/Makefile @@ -59,8 +59,10 @@ clean: ## Remove files generated by other targets .PHONY: cli-docs cli-docs: ## generate cli documenation + @echo "Generating the docs" rm -rf docs/content/reference && mkdir docs/content/reference cd docs/content/reference && $(GO) run -tags docs -exec 'env HOME=$$HOME' ../../../hack/generate-docs.go + @echo "Configuring the _index.md file with the appropriate header" NL=$$'\n'; sed -e "1,/---/ { /^title:/ { \ a \\$${NL}aliases:\\$${NL}- /reference/pgo\\$${NL}weight: 100$${NL}; \ c \\$${NL}title: Command Reference$${NL}; \ @@ -68,6 +70,7 @@ cli-docs: ## generate cli documenation docs/content/reference/pgo.md > \ docs/content/reference/_index.md rm docs/content/reference/pgo.md + @echo "Break out a separate code block for `Example output`" for filename in $(wildcard docs/content/reference/pgo_*.md); do \ NL=$$'\n'; \ sed -i "s/### Example output/\`\`\`\\$${NL}### Example output\\$${NL}\`\`\`/g" $${filename}; \ diff --git a/internal/cmd/pgo.go b/internal/cmd/pgo.go index 304a9871..332be8bb 100644 --- a/internal/cmd/pgo.go +++ b/internal/cmd/pgo.go @@ -90,6 +90,8 @@ func NewPGOCommand(stdin io.Reader, stdout, stderr io.Writer) *cobra.Command { {{end}}{{if or .Runnable .HasSubCommands}}{{.UsageString}}{{end}}`) + // We take the default UsageTemplate and alter it for our needs + // -- source: https://github.com/spf13/cobra/blob/main/command.go#UsageTemplate root.SetUsageTemplate(`Usage:{{if .Runnable}} {{.UseLine}}{{end}}{{if .HasAvailableSubCommands}} {{.CommandPath}} [command]{{end}}{{if gt (len .Aliases) 0}}