What happenedhelper.InitConfig gets called also for commands other than the currently running one.
What you expected to happenhelper.InitConfig gets called only for the currently running command.
How to reproduce it (as minimally and precisely as possible)
Add a println in the definition of helper.InitConfig and run any CLI - e.g. immuadmin.
Observe that InitConfig gets called for other commands too - output example:
./immuadmin user list
~~~~~> config name immudb
Using config file: /Users/ogg/ws/github/immudb/configs/immudb.toml
~~~~~> config name immugw
~~~~~> config name immuadmin
Environment
./immuadmin version
Using config file: /Users/ogg/ws/github/immudb/configs/immudb.toml
immuadmin v0.6.1
Commit : 611dbde030a198671081459550323dfc008078d5
Built by: 912518+padurean@users.noreply.github.com
Built at: Wed, 10 Jun 2020 20:12:30 EEST
Additional info (any other context about the problem)
Initialisation code like this should be moved (for all CLIs) from init to NewCmd
What happened
helper.InitConfig
gets called also for commands other than the currently running one.What you expected to happen
helper.InitConfig
gets called only for the currently running command.How to reproduce it (as minimally and precisely as possible) Add a
println
in the definition ofhelper.InitConfig
and run any CLI - e.g.immuadmin
. Observe thatInitConfig
gets called for other commands too - output example:Environment
Additional info (any other context about the problem) Initialisation code like this should be moved (for all CLIs) from
init
toNewCmd