From d2fdcbc0d4f8b4c184ba2b1c3c4b00da3918521f Mon Sep 17 00:00:00 2001 From: Benjamin Chausse Date: Wed, 26 Mar 2025 17:28:58 -0400 Subject: Stylish `--help` + generate manpages (#27) * man page generation * generate VHS Gifs manually * goreleaser packages manpage --- internal/documentation/documentation.go | 38 +++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 internal/documentation/documentation.go (limited to 'internal/documentation/documentation.go') diff --git a/internal/documentation/documentation.go b/internal/documentation/documentation.go new file mode 100644 index 0000000..3744eb0 --- /dev/null +++ b/internal/documentation/documentation.go @@ -0,0 +1,38 @@ +/* + * This package isn't the actual termpicker app. + * To avoid importing packages which aren't needed at runtime, + * some auto-generation functionalities is offloaded to here so + * it can be done with access to the rest of the code-base but + * without bloating the final binary. For example, + * generating bash+zsh auto-completion scripts isn't needed in + * the final binary if those script are generated before hand. + * Same goes for manpages. This file is meant to be run automatically + * to easily package new releases. Same goes for manpages which is the + * only feature currently in here. + */ +package main + +//go:generate go run . > termpicker.1 + +import ( + _ "embed" + "log/slog" + "os" + + "github.com/ChausseBenjamin/termpicker/internal/app" + docs "github.com/urfave/cli-docs/v3" +) + +func main() { + // version doesn't show up in the man page... + a := app.Command("") + + man, err := docs.ToManWithSection(a, 1) + if err != nil { + slog.Error("failed to generate man page", + slog.Any("error_message", err), + ) + os.Exit(1) + } + os.WriteFile("termpicker.1", []byte(man), 0644) +} -- cgit v1.2.3