-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Export help display functions as variables to allow custom help display logic #2150
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
Conversation
Is there something that is impossible with the current API/templates? |
The readability of Go templates is quite poor, which makes debugging difficult. Additionally, they are not flexible enough to support more advanced customization, such as using colors to distinguish between commands, flags, and so on. While it is possible to add custom functions to templates by defining a custom printer function, this approach is hard to maintain. For examples of more personalized requirements, please refer to @goravel/framework/pull/766. |
@almas-x Thanks for the PR. I looked at goravel/framework#766 . It seems to me you could have been best served by setting HelpPrinterCustom to your printHelperCustom ? Yes you would still be doing the hard work and you dont need to have cli library export the ShowAppHelp and everything right ? |
In goravel/framework#766, we replaced HelpPrinterCustom. However, as I mentioned earlier, Go’s template is difficult to read, maintain, and adapt for i18n. This makes it challenging to handle localization effectively. That’s why I propose exporting ShowXXXHelp for directly formatting and printing the help information. By avoiding template rendering, this approach is more intuitive, flexible, and better suited for addressing localization needs. |
How people are going to discover what is available in It would be nice to have some page listing all variables/props used. Maybe render them from JSON #1607 so that it won't be specific to functional cli API. |
I'm still not convinced having this would have helped @almas-x . Maybe I'm missing something . |
Perhaps I didn’t express myself clearly. My point is to export these |
What type of PR is this?
What this PR does / why we need it:
Exported
ShowAppHelp
,ShowCommandHelp
, andShowSubcommandHelp
as variables assigned to private functions.This allows users to override the help display logic for the app and commands, improving extensibility and flexibility for custom help behaviors.
Release Notes
(REQUIRED)