gradient-string icon indicating copy to clipboard operation
gradient-string copied to clipboard

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

Open cdwmhcc opened this issue 1 year ago • 4 comments

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!

cdwmhcc avatar Oct 05 '24 19:10 cdwmhcc

Hi @cdwmhcc

Opening an issue without any greeting or explanation and just dumping a piece of code is disrespectful to the time of open-source maintainers. If you expect help, the least you can do is explain your problem properly and approach the conversation with some basic manners.

I won’t be addressing this issue unless you provide proper context and communicate in a more respectful way.

bokub avatar Oct 05 '24 20:10 bokub

@bokub Thank you for your feedback. I apologize for my initial approach, as I did not provide the necessary details and did not respect your time as a maintainer. I now understand how important it is to provide complete information and communicate more thoughtfully. I did not quite understand the specific format required to submit an issue for gradient-string. I re-edited the issue. If there are any missing details, please let me know and I will add them. English is not my native language(I used google translate), so I hope you can forgive me if the wording and grammar are not accurate.

cdwmhcc avatar Oct 05 '24 20:10 cdwmhcc

Hello!

What happens if you use the same description but as a regular text instead of a gradient-colored one?

bokub avatar Oct 05 '24 21:10 bokub

What happens if you use the same description but as a regular text instead of a gradient-colored one?

I tried it and everything is normal and is a single line.

Here is an online example: https://stackblitz.com/edit/stackblitz-starters-bjcnsv?file=index.js Execute: node index.js

cdwmhcc avatar Oct 05 '24 22:10 cdwmhcc