Newbie question: how to _really_ change CommandHelpTemplate and where did AppHelpTemplate go? (v3) #2062
Labels
area/v3
relates to / is being considered for v3
kind/discussion
is for discussion
kind/question
someone asking a question
status/triage
maintainers still need to look into this
Hi there 👋 I'm currently using v3 to do some quick & dirty CLI applications. I've been often overwhelmed by the sheer size and complexity of this package, considering that the 'official' documentation just covers the bare essentials, and there are levels and levels of goodies hidden below the surface, if only you can understand how they all fit together.
A few of my odd experiments are targeted to a non-English-speaking audience. While I'm well aware that the whole issue of internationalisation/localisation of
cli
is postponed sine die, I have some questions regarding the proper use of the template system, with which a lot can already been done (and, most importantly, tweaked for specific purposes.I seem to have no issues whatsoever with
RootCommandHelpTemplate
— I can change it at will, and even those non-public templates it pulls in can be simply copied & pasted to the template (and then freely edited), and the 'root' or 'main' help does, indeed, use this template.Changing
CommandHelpTemplate
is another story: when I call my 'override' at the very beginning — i.e., before any command has been defined, it simply gets completely ignored, and the package continues to use its internally defined one. I haven't delved deep into the code to try to understand why.If called just before
cli.Run()
is called, then it does work — almost always. It just fails when calling help for a second alias, something that probably nobody in their right mind will have anyway. In my case, I discovered that by sheer luck — since, besides the usualhelp
command, with theh
alias, I had defined another one,ajuda
, which stands for, well, 'help', in Portuguese 🇵🇹 .More specifically, as far as I can test:
my-cmd help oneCmd
my-command help help
my-command help h
my-command help ajuda
my-command ajuda help
Curious, isn't it? (as said, I didn't look up the code for displaying help for the help aliases).
Last question... what exactly is the
AppHelpTemplate
, and under which circumstances can it be used? It figures extensively in the documentation (and elsewhere), but I can't find it anywhere in the v3 code itself. Is it something specific to pre-v3 versions, and just not consistently updated elsewhere? Was this template discontinued — or replaced by a different one? If so, what's the name of the replacement, please? I can't find anything similarly named — certainly it's not ontemplates.go
for sure.Alas, now I just need all other templates to be able to be overridden as well, and then I'll be a happy girl 👯♀️👧🤗
Maybe for v4...
The text was updated successfully, but these errors were encountered: