Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage does not auto indent newlines #1293

Closed
4 of 7 tasks
WestleyK opened this issue Aug 13, 2021 · 2 comments
Closed
4 of 7 tasks

Usage does not auto indent newlines #1293

WestleyK opened this issue Aug 13, 2021 · 2 comments
Labels
area/v2 relates to / is being considered for v2 kind/bug describes or fixes a bug status/triage maintainers still need to look into this
Milestone

Comments

@WestleyK
Copy link

my urfave/cli version is

v2.3.0

Checklist

  • Are you running the latest v2 release? The list of releases is here.
  • Did you check the manual for your release? The v2 manual is here
  • Did you perform a search about this problem? Here's the Github guide about searching.

Dependency Management

  • My project is using go modules.
  • My project is using vendoring.
  • My project is automatically downloading the latest version.
  • I am unsure of what my dependency management setup is.

Describe the bug

Usage does not auto indent newlines in usage.

Expected output:

$ ./foo 
NAME:
   foo - sample usage

USAGE:
   foo [global options] command [command options] [arguments...]

COMMANDS:
   run  this is a long help output for the run command, long usage
        output, long usage output, long usage output, long usage output  <-- notice the indent
   help, h  Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --help, -h  show help (default: false)

Actual output:

$ ./foo 
NAME:
   foo - sample usage

USAGE:
   foo [global options] command [command options] [arguments...]

COMMANDS:
   run  this is a long help output for the run command, long usage
output, long usage output, long usage output, long usage output  <-- not auto indenting
   help, h  Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --help, -h  show help (default: false)

To reproduce

Example
package main

import (
	"fmt"
	"os"

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

func main() {
	app := &cli.App{
		Usage: "sample usage",
		Commands: []*cli.Command{
			{
				Name:  "run",
				Usage: "this is a long help output for the run command, long usage\noutput, long usage output, long usage output, long usage output",
				Action: func(c *cli.Context) error {
					return fmt.Errorf("nothing")
				},
			},
		},
	}

	err := app.Run(os.Args)
	if err != nil {
		fmt.Fprintf(os.Stdout, "%s: %s\n", os.Args[0], err)
		os.Exit(1)
	}
}

Additional context

Related to: #1278

Run go version and paste its output here

go version go1.16.5 linux/amd64

Run go env and paste its output here

not relevant 
@WestleyK WestleyK added area/v2 relates to / is being considered for v2 kind/bug describes or fixes a bug status/triage maintainers still need to look into this labels Aug 13, 2021
kchugalinskiy added a commit to kchugalinskiy/cli that referenced this issue Aug 17, 2021
Fix issue by adding custom replaceAll function and replacing all newlines by newlines+spaces in command usage description
kchugalinskiy added a commit to kchugalinskiy/cli that referenced this issue Aug 17, 2021
Fix issue by adding custom replaceAll function and replacing all newlines by newlines+spaces in command usage description
kchugalinskiy added a commit to kchugalinskiy/cli that referenced this issue Aug 17, 2021
Fix issue by adding custom replaceAll function and replacing all newlines by newlines+spaces in command usage description
kchugalinskiy added a commit to kchugalinskiy/cli that referenced this issue Aug 18, 2021
Fix issue by adding custom replaceAll function and replacing all newlines by newlines+spaces in command usage description
@meatballhat meatballhat changed the title v2 bug: Usage does not auto indent newlines Usage does not auto indent newlines Apr 21, 2022
@dearchap
Copy link
Contributor

@WestleyK I have a new PR #1460 which fixes this. Can you test and see ?

@dearchap
Copy link
Contributor

PR #1460 fixes this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/v2 relates to / is being considered for v2 kind/bug describes or fixes a bug status/triage maintainers still need to look into this
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants