Skip to content

Formatting Issue: Inconsistent display with commander.js and gradient-string #10

Description

@cdwmhcc

Description

Dear Developers, I am experiencing a formatting discrepancy when using gradient-string along with commander.js to create a command-line tool. The text outputted by console.log appears in color and on a single line as expected. However, the same text used in the description of a command in commander.js ends up being displayed over multiple lines.

Environment

  • Operating System: Windows 11
  • Node.jsn: 20.18.0
  • gradient-string: 3.0.0
  • commander: 12.1.0

Code Sample

import { Command } from 'commander'
import gradient, { atlas } from 'gradient-string'


const DESCRIPTIONS = gradient(['cyan', 'pink'])('H e l l o w o r l d!')
console.log(DESCRIPTIONS) // Here is a single line display
const program = new Command()

program.name('string-util')
  .description(DESCRIPTIONS) // Here it becomes multiple lines
  .version('0.8.0')

program.command('split')
  .description('Split a string into substrings and display as an array')
  .argument('<string>', 'string to split')

program.parse();

Image

image

Expected Behavior

I expect the description in commander.js to maintain a single line display, similar to the console.log output.

Could this issue be related to how commander.js handles descriptions, or is it an issue with the way gradient-string processes the text? Thank you for your assistance!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions