Skip to content

Export help display functions as variables to allow custom help display logic#2150

Merged
dearchap merged 2 commits intourfave:mainfrom
almas-x:main
Jul 13, 2025
Merged

Export help display functions as variables to allow custom help display logic#2150
dearchap merged 2 commits intourfave:mainfrom
almas-x:main

Conversation

@almas-x
Copy link
Copy Markdown
Contributor

@almas-x almas-x commented Jun 5, 2025

What type of PR is this?

  • feature

What this PR does / why we need it:

  • Exported ShowAppHelp, ShowCommandHelp, and ShowSubcommandHelp 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)

Exported `ShowAppHelp`, `ShowCommandHelp`, and `ShowSubcommandHelp` as variables assigned to private functions, allowing users to override help display logic for custom behaviors.

@almas-x almas-x requested a review from a team as a code owner June 5, 2025 06:27
@almas-x almas-x changed the title feat: export ShowCommandHelp and ShowSubcommandHelp as variables for user override feat: export ShowAppHelp, ShowCommandHelp, and ShowSubcommandHelp as variables to allow custom help display logic Jun 5, 2025
@almas-x almas-x changed the title feat: export ShowAppHelp, ShowCommandHelp, and ShowSubcommandHelp as variables to allow custom help display logic feat: export help display functions as variables to allow custom help display logic Jun 5, 2025
@abitrolly
Copy link
Copy Markdown
Contributor

Is there something that is impossible with the current API/templates?

@almas-x
Copy link
Copy Markdown
Contributor Author

almas-x commented Jun 5, 2025

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.

@dearchap
Copy link
Copy Markdown
Contributor

dearchap commented Jun 5, 2025

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

@almas-x
Copy link
Copy Markdown
Contributor Author

almas-x commented Jun 5, 2025

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

@abitrolly
Copy link
Copy Markdown
Contributor

How people are going to discover what is available in cmd object to produce help?

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.

@dearchap
Copy link
Copy Markdown
Contributor

dearchap commented Jun 7, 2025

I'm still not convinced having this would have helped @almas-x . Maybe I'm missing something .

@almas-x
Copy link
Copy Markdown
Contributor Author

almas-x commented Jun 7, 2025

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 ShowXXXHelp methods so that when printing help information, we can directly use something like fmt.Sprintf within these methods for output, instead of relying on template rendering. This way, it allows for i18n handling or adding color formatting before fmt.Sprintf, reducing the limitations compared to templates. If you still feel this doesn’t add much value, please go ahead and help close this PR.

@meatballhat meatballhat added kind/feature describes a code enhancement / feature request area/v3 relates to / is being considered for v3 labels Jun 14, 2025
@meatballhat meatballhat changed the title feat: export help display functions as variables to allow custom help display logic Export help display functions as variables to allow custom help display logic Jun 14, 2025
@almas-x almas-x closed this Jun 16, 2025
@almas-x almas-x reopened this Jun 23, 2025
@dearchap dearchap merged commit 9cd5d9c into urfave:main Jul 13, 2025
7 checks passed
schwarlex pushed a commit to la-demos/vcluster-workshop-prep that referenced this pull request Feb 11, 2026
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [github.com/urfave/cli/v3](https://github.com/urfave/cli) | require | minor | `v3.3.8` -> `v3.6.1` |

---

### Release Notes

<details>
<summary>urfave/cli (github.com/urfave/cli/v3)</summary>

### [`v3.6.1`](https://github.com/urfave/cli/releases/tag/v3.6.1)

[Compare Source](urfave/cli@v3.6.0...v3.6.1)

#### What's Changed

- chore(deps): bump golangci/golangci-lint-action from 8 to 9 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2222](urfave/cli#2222)
- feat: add ability to override usage text of default help command by [@&#8203;Maks1mS](https://github.com/Maks1mS) in [#&#8203;2196](urfave/cli#2196)
- Fix:(issue\_2223) Fix incorrect processing of empty value after = by [@&#8203;dearchap](https://github.com/dearchap) in [#&#8203;2224](urfave/cli#2224)

#### New Contributors

- [@&#8203;Maks1mS](https://github.com/Maks1mS) made their first contribution in [#&#8203;2196](urfave/cli#2196)

**Full Changelog**: <urfave/cli@v3.6.0...v3.6.1>

### [`v3.6.0`](https://github.com/urfave/cli/releases/tag/v3.6.0)

[Compare Source](urfave/cli@v3.5.0...v3.6.0)

#### What's Changed

- support parallel running of commands by [@&#8203;oprudkyi](https://github.com/oprudkyi) in [#&#8203;2215](urfave/cli#2215)
- Fix:(issue\_2208) Fix local flag by [@&#8203;dearchap](https://github.com/dearchap) in [#&#8203;2211](urfave/cli#2211)
- chore(deps): bump the python-packages group with 2 updates by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2219](urfave/cli#2219)
- Call actions on flags set from env by [@&#8203;malclocke](https://github.com/malclocke) in [#&#8203;2221](urfave/cli#2221)

#### New Contributors

- [@&#8203;malclocke](https://github.com/malclocke) made their first contribution in [#&#8203;2221](urfave/cli#2221)

**Full Changelog**: <urfave/cli@v3.5.0...v3.6.0>

### [`v3.5.0`](https://github.com/urfave/cli/releases/tag/v3.5.0)

[Compare Source](urfave/cli@v3.4.1...v3.5.0)

#### What's Changed

- Update mkdocs reqs by [@&#8203;meatballhat](https://github.com/meatballhat) in [#&#8203;2190](urfave/cli#2190)
- Allow the user to stop processing flags after seeing N args by [@&#8203;adrian-thurston](https://github.com/adrian-thurston) in [#&#8203;2163](urfave/cli#2163)
- chore(deps): bump github.com/stretchr/testify from 1.10.0 to 1.11.0 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2194](urfave/cli#2194)
- chore(deps): bump mkdocs-material from 9.6.16 to 9.6.18 in the python-packages group by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2195](urfave/cli#2195)
- chore(deps): bump actions/setup-go from 5 to 6 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2198](urfave/cli#2198)
- chore(deps): bump actions/setup-node from 4 to 5 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2199](urfave/cli#2199)
- chore(deps): bump actions/setup-python from 5 to 6 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2200](urfave/cli#2200)
- chore(deps): bump github.com/stretchr/testify from 1.11.0 to 1.11.1 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2197](urfave/cli#2197)
- chore(deps): bump mkdocs-material from 9.6.18 to 9.6.19 in the python-packages group by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2201](urfave/cli#2201)
- chore(deps): bump mkdocs-material from 9.6.19 to 9.6.20 in the python-packages group by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2202](urfave/cli#2202)
- feat: add name of argument into error message when parsing fails by [@&#8203;oprudkyi](https://github.com/oprudkyi) in [#&#8203;2203](urfave/cli#2203)
- chore(deps): bump mkdocs-material from 9.6.20 to 9.6.21 in the python-packages group by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2204](urfave/cli#2204)
- add space between arguments usage by [@&#8203;dimfu](https://github.com/dimfu) in [#&#8203;2207](urfave/cli#2207)
- chore(deps): bump mkdocs-material from 9.6.21 to 9.6.22 in the python-packages group by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2213](urfave/cli#2213)
- Fix: Make DefaultText behaviour consistent by [@&#8203;dearchap](https://github.com/dearchap) in [#&#8203;2214](urfave/cli#2214)

#### New Contributors

- [@&#8203;adrian-thurston](https://github.com/adrian-thurston) made their first contribution in [#&#8203;2163](urfave/cli#2163)
- [@&#8203;oprudkyi](https://github.com/oprudkyi) made their first contribution in [#&#8203;2203](urfave/cli#2203)
- [@&#8203;dimfu](https://github.com/dimfu) made their first contribution in [#&#8203;2207](urfave/cli#2207)

**Full Changelog**: <urfave/cli@v3.4.1...v3.5.0>

### [`v3.4.1`](https://github.com/urfave/cli/releases/tag/v3.4.1)

[Compare Source](urfave/cli@v3.4.0...v3.4.1)

#### What's Changed

- Use recommended GitHub Actions runner labels by [@&#8203;meatballhat](https://github.com/meatballhat) in [#&#8203;2181](urfave/cli#2181)
- chore(deps): bump actions/checkout from 4 to 5 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2179](urfave/cli#2179)
- Document that `v3` series is recommended for new development by [@&#8203;meatballhat](https://github.com/meatballhat) in [#&#8203;2186](urfave/cli#2186)

**Full Changelog**: <urfave/cli@v3.4.0...v3.4.1>

### [`v3.4.0`](https://github.com/urfave/cli/releases/tag/v3.4.0)

[Compare Source](urfave/cli@v3.3.9...v3.4.0)

#### What's Changed

- Export help display functions as variables to allow custom help display logic by [@&#8203;almas-x](https://github.com/almas-x) in [#&#8203;2150](urfave/cli#2150)
- Invoke OnUsageError when missing required flags by [@&#8203;MohitPanchariya](https://github.com/MohitPanchariya) in [#&#8203;2161](urfave/cli#2161)
- Fix:(issue\_2169) Allow trim space for string slice flags by [@&#8203;dearchap](https://github.com/dearchap) in [#&#8203;2171](urfave/cli#2171)
- Add example of flag groups to docs by [@&#8203;jllovet](https://github.com/jllovet) in [#&#8203;2178](urfave/cli#2178)
- Add installation instructions for gfmrun by [@&#8203;jllovet](https://github.com/jllovet) in [#&#8203;2177](urfave/cli#2177)
- Ensure public vars reference public types by [@&#8203;meatballhat](https://github.com/meatballhat) in [#&#8203;2180](urfave/cli#2180)

#### New Contributors

- [@&#8203;almas-x](https://github.com/almas-x) made their first contribution in [#&#8203;2150](urfave/cli#2150)
- [@&#8203;MohitPanchariya](https://github.com/MohitPanchariya) made their first contribution in [#&#8203;2161](urfave/cli#2161)
- [@&#8203;jllovet](https://github.com/jllovet) made their first contribution in [#&#8203;2178](urfave/cli#2178)

**Full Changelog**: <urfave/cli@v3.3.9...v3.4.0>

### [`v3.3.9`](https://github.com/urfave/cli/releases/tag/v3.3.9)

[Compare Source](urfave/cli@v3.3.8...v3.3.9)

#### What's Changed

- Fix typos in documentation for customizations and full API example by [@&#8203;amarjit03](https://github.com/amarjit03) in [#&#8203;2165](urfave/cli#2165)
- Update advanced.md by [@&#8203;thetillhoff](https://github.com/thetillhoff) in [#&#8203;2170](urfave/cli#2170)

#### New Contributors

- [@&#8203;amarjit03](https://github.com/amarjit03) made their first contribution in [#&#8203;2165](urfave/cli#2165)
- [@&#8203;thetillhoff](https://github.com/thetillhoff) made their first contribution in [#&#8203;2170](urfave/cli#2170)

**Full Changelog**: <urfave/cli@v3.3.8...v3.3.9>

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MS4xMjcuMiIsInVwZGF0ZWRJblZlciI6IjQxLjE3My4xIiwidGFyZ2V0QnJhbmNoIjoibWFzdGVyIiwibGFiZWxzIjpbXX0=-->

Reviewed-on: https://kubara.git.onstackit.cloud/STACKIT/kubara/pulls/100
Co-authored-by: Matthias_Huether <matthias.huether_ext@external.stackit.cloud>
Co-committed-by: Matthias_Huether <matthias.huether_ext@external.stackit.cloud>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/v3 relates to / is being considered for v3 kind/feature describes a code enhancement / feature request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants