unjs / citty

🌆 Elegant CLI Builder
Other
697 stars 23 forks source link

Mechanism to customize each part displayed by `showUsage` #137

Open kazupon opened 3 months ago

kazupon commented 3 months ago

If you can make an issue to explain or visually share some screenshot of desired output i can help to improve built-in showUsage usable for rolldown.

Originally posted by @pi0 in https://github.com/unjs/citty/issues/135#issuecomment-2043033387

The showUsage currently provided can be customized with own customized showUsage in runMain, but there is no way to customize the built-in showUsage that citty has.

The showUsage renders the following parts via renderUsage.

It would be useful to have a mechanism to custom render each of these parts, so that the logic of showUsage does not have to be reused.

In the rolldown use case, we would like to customize only the header.

pi0 commented 3 months ago

Hi. Sure we can think of some kind of text AST structure to allow hooking into and modifying the output 👍🏼

In the rolldown use case, we would like to customize only the header.

I want to investigate this first although. Can you share the desired header change? If it is more beautiful, i am up to simply update the default usage to it so not going to the customization path :)

kazupon commented 3 months ago

I want to investigate this first although. Can you share the desired header change? If it is more beautiful, i am up to simply update the default usage to it so not going to the customization path :)

@pi0 Thanks!

rolldown header test is here:

rolldown 0.10.1 - Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.

rolldown header image is here:

image

rolldown cli is a layout and color adjustment for the header customization.