Skip to content

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

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

Open
cdwmhcc opened this issue Oct 5, 2024 · 4 comments

Comments

@cdwmhcc
Copy link

cdwmhcc commented Oct 5, 2024

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!

@bokub
Copy link
Owner

bokub commented Oct 5, 2024

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.

@cdwmhcc cdwmhcc changed the title Incorrect format in commander.js Formatting Issue: Inconsistent display with commander.js and gradient-string Oct 5, 2024
@cdwmhcc
Copy link
Author

cdwmhcc commented Oct 5, 2024

@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.

@bokub
Copy link
Owner

bokub commented Oct 5, 2024

Hello!

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

@cdwmhcc
Copy link
Author

cdwmhcc commented Oct 5, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants