cli
cli copied to clipboard
Keep indentation in help/usage text
Fix issue by adding custom replaceAll function and replacing all newlines by newlines+spaces in command usage description
Some new spaces would align command usage and fulfill user needs
What type of PR is this?
- bug
What this PR does / why we need it:
I've added new custom function into the template. I assume this is fine because similar workaround has been introduced for join
function. I didn't fix indent if user just types in long usage without any newlines and I expect it isn't possible, cause user screen width is unknown
Which issue(s) this PR fixes:
Fixes #1293
Testing
Tested by using the test case provided by user, by adding/removing some newlines
Release Notes
User may use newlines to correctly align usage section of help.
yes, surely! let me do it later on today
Hi @kchugalinskiy! I downloaded your branch and tested my example code in my issue, and it almost works. It indents it, but not all the way:
$ ./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
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS:
--help, -h show help (default: false)
I'm not sure if thats by your design, however I was expecting it to indent it until where the usage help starts.
@WestleyK could you please give a sample output of how it should work in your opinion? I was just indenting everything that is newline-separated. I cannot calculate your screen width (well, actually I could use ncurses, but I would prefer not to summon demons)
Yeah, I dont think summoning demons/daemons would be the solution here, Lol!
I would normally expect an output like this:
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
See how it indents the newline until the usage starts.
However, this indent amount would change. For example if you run: (edited output)
$ ./foo run --help
NAME:
foo run - this is a long help output for the run command, long usage
output, long usage output, long usage output, long usage output
[...]
It would need to indent it more. And this would change from command to command.
I'm honestly not sure if this is an easy fix. Indenting it like you have here is defiantly better then nothing, however I'm not sure if this "ideal" indenting is possible with this cli package.
Hi @kchugalinskiy, do you have a plan moving forwarded? Whats the status here?
PR #1460 fixes this. Can I close this PR ?