From af690d653aab18887b743736f46cf172242e67fd Mon Sep 17 00:00:00 2001 From: Amolith Date: Tue, 21 Oct 2025 17:15:34 -0600 Subject: [PATCH] docs: improve CLI examples and make flags optional Co-authored-by: Crush --- main.go | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index b04528cd48a6f3e4f52f23db5a109ab1f371890a..5a746773ec33bab5dd8a322d64fbdbafbffa96de 100644 --- a/main.go +++ b/main.go @@ -24,6 +24,24 @@ var rootCmd = &cobra.Command{ Long: `formatted-commit helps you create well-formatted Git commits that follow the Conventional Commits specification with proper subject length validation, body wrapping, and trailer formatting.`, + Example: ` +# With co-author +formatted-commit -t feat -m "do a thing" -T "Crush " + +# Breaking change with longer body +formatted-commit -t feat -m "do a thing that borks a thing" -B "$(cat <<'EOF' +Multi-line +- Body +- Here + +This is what borked because of new shiny, this is how migrate +EOF +)" + +# Including scope for more precise changes +formatted-commit -t refactor -s "web/git-bug" -m "fancy shmancy" \ + -b "Had to do a weird thing because..." +`, RunE: func(cmd *cobra.Command, args []string) error { // TODO: Implement commit formatting logic here // 1. Validate subject length (type(scope): message <= 50 chars) @@ -38,15 +56,13 @@ body wrapping, and trailer formatting.`, func init() { rootCmd.Flags().StringVarP(&commitType, "type", "t", "", "commit type (required)") rootCmd.Flags().StringVarP(&message, "message", "m", "", "commit message (required)") - rootCmd.Flags().StringSliceVarP(&trailers, "trailer", "T", []string{}, "trailer in 'Key: value' format (required, repeatable)") - rootCmd.Flags().StringVarP(&body, "body", "b", "", "commit body (required)") + rootCmd.Flags().StringSliceVarP(&trailers, "trailer", "T", []string{}, "trailer in 'Sentence-case-key: value' format (optional, repeatable)") + rootCmd.Flags().StringVarP(&body, "body", "b", "", "commit body (optional)") rootCmd.Flags().StringVarP(&scope, "scope", "s", "", "commit scope (optional)") rootCmd.Flags().BoolVarP(&breakingChange, "breaking", "B", false, "mark as breaking change (optional)") rootCmd.MarkFlagRequired("type") rootCmd.MarkFlagRequired("message") - rootCmd.MarkFlagRequired("trailer") - rootCmd.MarkFlagRequired("body") } func main() {