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

hideCommandSummaryInDescription removes description when missing a line feed #1243

Open
daymxn opened this issue Nov 22, 2024 · 1 comment
Open
Labels
--help output Related to --help output bug Something isn't working good first issue Good for newcomers help wanted Accepting PRs

Comments

@daymxn
Copy link

daymxn commented Nov 22, 2024

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.

@mdonnalley mdonnalley added help wanted Accepting PRs good first issue Good for newcomers --help output Related to --help output bug Something isn't working labels Nov 26, 2024
Copy link

git2gus bot commented Nov 26, 2024

This issue has been linked to a new work item: W-17318299

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
--help output Related to --help output bug Something isn't working good first issue Good for newcomers help wanted Accepting PRs
Projects
None yet
Development

No branches or pull requests

2 participants