hcloud-upload-image/scripts/cli-help-pages.go
Julian Tölle 4e24d83c7a
docs: add generated CLI help output to repo (#46)
Generate the help pages using `cobras` builtin functionality and commit
them to the repository. This gives users to ability to review the
options of `hcloud-upload-image` without having to install it first.
2024-11-02 21:57:53 +01:00

36 lines
667 B
Go

package main
import (
"fmt"
"os"
"github.com/spf13/cobra/doc"
"github.com/apricote/hcloud-upload-image/cmd"
)
func run() error {
// Define the directory where the docs will be generated
dir := "docs/cli"
// Ensure the directory exists
if err := os.MkdirAll(dir, 0755); err != nil {
return fmt.Errorf("error creating docs directory: %v", err)
}
// Generate the docs
if err := doc.GenMarkdownTree(cmd.RootCmd, dir); err != nil {
return fmt.Errorf("error generating docs: %v", err)
}
fmt.Println("Docs generated successfully in", dir)
return nil
}
func main() {
if err := run(); err != nil {
fmt.Printf("Error: %v\n", err)
os.Exit(1)
}
}