-
Notifications
You must be signed in to change notification settings - Fork 86
Closed
Labels
--help outputRelated to --help outputRelated to --help outputbugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomershelp wantedAccepting PRsAccepting PRs
Description
Describe the bug
When using the hideCommandSummaryInDescription option of HelpOptions, if the command description doesn't start with a line feed, then the description is lost in the output.
To Reproduce
import { Command, CommandHelp } from "@oclif/core";
export class CoolCommand extends Command {
static override description = "Cool description.";
static override summary = "Cool summary";
async run() {
const command = this.config.findCommand(this.id!);
const help = new CommandHelp(command!, this.config, {
hideCommandSummaryInDescription: true,
maxWidth: 120,
});
console.log(help.generate());
}
}Expected behavior
USAGE
$ my-cli cool
DESCRIPTION
Cool description.
Actual behavior
USAGE
$ my-cli cool
Environment:
- OS & version: Windows 10
- Shell/terminal & version: Windows Terminal w/ powershell
Additional context
The problem comes from this line.
The usage of slice here is dropping the description if it doesn't start with a newline character.
I believe this behavior is here to support situations like this:
export class CoolCommand extends Command {
static override description = `
Cool description.`;
}Although, I'd argue that's an end-user problem. One that's easily fixed with trim:
export class CoolCommand extends Command {
static override description = `
Cool description.`.trim();
}Alternatively, oclif could call trim instead of slice, but that's making assumptions about end-user's descriptions.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
--help outputRelated to --help outputRelated to --help outputbugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomershelp wantedAccepting PRsAccepting PRs