Skip to content

Conversation

shadowspawn
Copy link
Collaborator

@shadowspawn shadowspawn commented Oct 7, 2024

This is built on top of #2251 to add simple text style hooks. The style hooks do not get passed enough to do complex coloring, but this allows adding color without needing to subclass Help and Command.

program.usage(
  `${styleText('green', '[options]')} ${styleText('yellow', '[command]')}`,
);
program.configureHelp({
  styleTitle: (str) => styleText('bold', str),
  styleDescription: (str) => styleText('magenta', str),
  styleItemDescription: (str) => styleText('italic', str),
  styleOptionTerm: (str) => styleText('green', str),
  styleSubcommandTerm: (str) => styleText('yellow', str),
});
style-output

@shadowspawn
Copy link
Collaborator Author

Lot of simple hooks, but I think it makes simple styling much easier for author. I am going to do some more work in this direction to try and have matching colours in "usage" transparently.

@shadowspawn
Copy link
Collaborator Author

Closing as merged into #2251.
Prototype went well!

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

Successfully merging this pull request may close these issues.

1 participant