urfave / cli

A simple, fast, and fun package for building command line apps in Go
https://cli.urfave.org
MIT License
21.9k stars 1.69k forks source link

include a newline between different categories #1861

Closed abennett closed 2 months ago

abennett commented 5 months ago

What type of PR is this?

What this PR does / why we need it:

The docs show a newline between categories in the default help output. This change adds the newline and makes the actual output consistent with documentation.

Which issue(s) this PR fixes:

N/A

Special notes for your reviewer:

Appreciate your work!

Testing

Using the example:

package main

import (
    "context"
    "log"
    "os"

    "github.com/urfave/cli/v3"
)

func main() {
    app := &cli.Command{
        Commands: []*cli.Command{
            {
                Name: "noop",
            },
            {
                Name:     "add",
                Category: "template",
            },
            {
                Name:     "remove",
                Category: "template",
            },
        },
    }

    if err := app.Run(context.Background(), os.Args); err != nil {
        log.Fatal(err)
    }
}

Diff:

diff --git a/before b/after
index b89e493..498ee0e 100644
--- a/before
+++ b/after
@@ -7,6 +7,7 @@ USAGE:
 COMMANDS:
    noop     
    help, h  Shows a list of commands or help for one command
+
    template:
      add     
      remove  

Release Notes

Add a newline between command categories.
abennett commented 5 months ago

What's the best way to get this ported to v2 as well?

dearchap commented 5 months ago

@abennett You have a raise a PR against v2 as well. Can you fix the failing tests here ?

abennett commented 5 months ago

@abennett You have a raise a PR against v2 as well. Can you fix the failing tests here ?

I can definitely create another PR. 👍

Uploading to codecov caused the failure. I could reattempt.