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
Make help indentation configurable #741
Comments
I'm currently using the following patch as a workaround: const { Command } = require('commander')
const helpInformation = Command.prototype.helpInformation
const indentation = ' '
Command.prototype.helpInformation = function () {
return helpInformation.call(this).split(/^/m).reduce((accum, line) => {
if (line === '\n') {
const lastLine = accum[accum.length - 1]
if (!lastLine || !(lastLine === '\n' || lastLine.endsWith(':\n'))) {
accum.push(line)
}
} else {
accum.push(line.substr(indentation.length))
}
return accum
}, []).join('')
} I'd also like to remove the extra blank line between sections. |
Try this: const { Command } = require('commander') Command.prototype.helpInformation = function () { |
That's effectively the same as what I proposed. |
For interest, the help indentation was removed in commander v2.18.0 via this Pull Request: #853 |
Now that the help output has been standardized, I no longer think that configuration of the indentation is necessary. I had only proposed that as a compromise for changing the default behavior. But now that the default has changed, I think we're good. 👍 |
commander.js indents all lines in the help output. This is atypical. I don't know many commands that output help with this formatting (if you consider node, npm, lerna, ruby, docker, git, grep, find, vim, rpm). I'd like to make my command look more like the typical command. Please make the indentation size configurable, or provide a switch to disable it outright.
Commands which do use indentation include yarn and gem. Yarn happens to have indentation because it's using this package ;)
The text was updated successfully, but these errors were encountered: