unjs / citty

πŸŒ† Elegant CLI Builder
Other
729 stars 23 forks source link

feat: exports low level APIs #135

Open kazupon opened 5 months ago

kazupon commented 5 months ago

πŸ”— Linked issue

https://github.com/rolldown/rolldown/pull/754#pullrequestreview-1981812870

❓ Type of change

πŸ“š Description

This PR will provide low level API runRawMain.

This makes it possible to implement command execution and error handling in the user's real parent. It also exports useful helpers and utilities for runRawMain and showUsage.

When showUsage is specified for runMain, it allows tree-shaking of citty's showUsage and renderUsage.

The function name runRawMain may be less desirable. I tried to be making showUsage (renderUsage) customizable, but the complexity of the current implementation made generalization hard.

πŸ“ Checklist

pi0 commented 5 months ago

Hi, and thanks for attempting this PR.

We need to properly go through exposed utils one by one in separate issues/PR and i think this one is not mergable like this. But overall:

kazupon commented 5 months ago

Thank you quick reply.

Sorry, I sent the wrong PR. I was overworked for the issue I would like to solve.

  • It seems we forgot the main topic in related discussion. What exact customization you expect for built-in usage about title? Maybe can you please open an issue to describe it? I can be happy to help applying it.

I've put reproduction repo https://github.com/kazupon/citty-repro1

kazupon commented 5 months ago

sorry, I'm going to open the new issue.

pi0 commented 5 months ago

Yes i undrestand you need to override built-in showUsage and that by doing it the built-in one is still bundled.

What I'm wondering is that what can be improved for built-in showUsage to be usable by rolldown directly without needing a custom one. 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.

(having basic run main without dependency is still good idea)

kazupon commented 5 months ago

I am so sorry. Sound like I've have missed with my comments. I created the issue at the following URL: https://github.com/unjs/citty/issues/136