fix: help/version override for translation

See toolshed/abra#628
This commit is contained in:
2025-09-03 08:53:08 +02:00
parent e1f029d2db
commit 4547cf2579
4 changed files with 168 additions and 46 deletions

View File

@ -5,6 +5,8 @@ var (
Debug bool
NoInput bool
Offline bool
Help bool
Version bool
// NOTE(d1): sub-command specific
Chaos bool

View File

@ -47,6 +47,29 @@ Additional help topics:{{range .Commands}}{{if .IsAdditionalHelpTopicCommand}}
Use "{{.CommandPath}} [command] --help" for more information about a command.{{end}}
`)
helpCmd = &cobra.Command{
Use: i18n.G("help [command]"),
// translators: Short description for `help` command
Short: i18n.G("Help about any command"),
Long: i18n.G(`Help provides help for any command in the application.
Simply type abra help [path to command] for full details.`),
Run: func(c *cobra.Command, args []string) {
cmd, _, e := c.Root().Find(args)
if cmd == nil || e != nil {
c.Print(i18n.G("unknown help topic %#q\n", args))
if err := c.Root().Usage(); err != nil {
log.Fatal(err)
}
} else {
cmd.InitDefaultHelpFlag()
cmd.InitDefaultVersionFlag()
if err := cmd.Help(); err != nil {
log.Fatal(err)
}
}
},
}
)
func Run(version, commit string) {
@ -122,6 +145,7 @@ Config:
rootCmd.CompletionOptions.DisableDefaultCmd = true
rootCmd.SetUsageTemplate(usageTemplate)
rootCmd.SetHelpCommand(helpCmd)
// translators: `abra man` aliases. use a comma separated list of aliases
// with no spaces in between
@ -185,6 +209,22 @@ Config:
i18n.G("prefer offline & filesystem access"),
)
rootCmd.PersistentFlags().BoolVarP(
&internal.Help,
i18n.G("help"),
i18n.G("h"),
false,
i18n.G("help for abra"),
)
rootCmd.PersistentFlags().BoolVarP(
&internal.Version,
i18n.G("version"),
i18n.G("v"),
false,
i18n.G("version for abra"),
)
catalogue.CatalogueCommand.AddCommand(
catalogue.CatalogueGenerateCommand,
catalogue.CatalogueSyncCommand,

View File

@ -7,7 +7,7 @@
msgid ""
msgstr "Project-Id-Version: \n"
"Report-Msgid-Bugs-To: EMAIL\n"
"POT-Creation-Date: 2025-09-03 00:25+0200\n"
"POT-Creation-Date: 2025-09-03 08:57+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -43,7 +43,7 @@ msgid " # fetch from recipe catalogue\n"
" abra recipe fetch gitea --ssh"
msgstr ""
#: ./cli/run.go:136
#: ./cli/run.go:160
msgid " # generate the man pages into /usr/local/share/man/man1\n"
" abra_path=$(which abra) # pass abra absolute path to sudo below\n"
" sudo $abra_path man\n"
@ -857,7 +857,7 @@ msgid "Generate labels for the main recipe service.\n"
msgstr ""
#. translators: Short description for `man` command
#: ./cli/run.go:135
#: ./cli/run.go:159
msgid "Generate manpage"
msgstr ""
@ -887,6 +887,16 @@ msgstr ""
msgid "HOST"
msgstr ""
#. translators: Short description for `help` command
#: ./cli/run.go:54
msgid "Help about any command"
msgstr ""
#: ./cli/run.go:55
msgid "Help provides help for any command in the application.\n"
"Simply type abra help [path to command] for full details."
msgstr ""
#: ./cli/app/ps.go:187 ./cli/recipe/version.go:69
msgid "IMAGE"
msgstr ""
@ -1304,14 +1314,14 @@ msgid "The Co-op Cloud auto-updater 🤖 🚀"
msgstr ""
#. translators: Short description for `abra` binary
#: ./cli/run.go:57
#: ./cli/run.go:80
msgid "The Co-op Cloud command-line utility belt 🎩🐇"
msgstr ""
#. translators: Long description for `abra` binary. This needs to be
#. translated in the same way as the Short description so that everything
#. matches up
#: ./cli/run.go:61
#: ./cli/run.go:84
#, c-format
msgid "The Co-op Cloud command-line utility belt 🎩🐇\n"
"\n"
@ -1637,7 +1647,7 @@ msgid "aborting as requested"
msgstr ""
#. translators: `abra` binary name
#: ./cli/run.go:55
#: ./cli/run.go:78
msgid "abra [cmd] [args] [flags]"
msgstr ""
@ -1645,7 +1655,7 @@ msgstr ""
msgid "abra app labels 1312.net"
msgstr ""
#: ./cli/run.go:114
#: ./cli/run.go:137
#, c-format
msgid "abra version: %s, commit: %s, lang: %s"
msgstr ""
@ -1721,7 +1731,7 @@ msgid "ambiguous service list received, prompting for input"
msgstr ""
#. translators: `abra app` command for autocompletion
#: ./cli/run.go:68
#: ./cli/run.go:91
msgid "app"
msgstr ""
@ -1779,7 +1789,7 @@ msgid "attempting to scale %s to 1"
msgstr ""
#. translators: `abra autocomplete` command for autocompletion
#: ./cli/run.go:70
#: ./cli/run.go:93
msgid "autocomplete"
msgstr ""
@ -1955,7 +1965,7 @@ msgid "cannot use [version] and --latest together"
msgstr ""
#. translators: `abra catalogue` command for autocompletion
#: ./cli/run.go:72
#: ./cli/run.go:95
msgid "catalogue"
msgstr ""
@ -2438,7 +2448,7 @@ msgstr ""
msgid "domain name for app"
msgstr ""
#: ./cli/run.go:160
#: ./cli/run.go:184
msgid "don't forget to run 'sudo mandb'"
msgstr ""
@ -3055,6 +3065,10 @@ msgstr ""
msgid "git: opening repository in %s"
msgstr ""
#: ./cli/run.go:215
msgid "h"
msgstr ""
#: ./cli/recipe/new.go:94
msgid "happy hacking 🎉"
msgstr ""
@ -3071,6 +3085,18 @@ msgstr ""
msgid "healthcheck enabled for all services"
msgstr ""
#: ./cli/run.go:214
msgid "help"
msgstr ""
#: ./cli/run.go:52
msgid "help [command]"
msgstr ""
#: ./cli/run.go:217
msgid "help for abra"
msgstr ""
#: ./cli/app/restore.go:129
msgid "hooks"
msgstr ""
@ -3411,7 +3437,7 @@ msgstr ""
#. with no spaces in between
#. translators: `abra man` aliases. use a comma separated list of aliases
#. with no spaces in between
#: ./cli/app/list.go:318 ./cli/app/move.go:34 ./cli/app/ps.go:205 ./cli/app/secret.go:553 ./cli/app/secret.go:649 ./cli/recipe/list.go:104 ./cli/recipe/upgrade.go:376 ./cli/recipe/version.go:139 ./cli/run.go:128 ./cli/server/list.go:106 ./cli/updater/updater.go:560
#: ./cli/app/list.go:318 ./cli/app/move.go:34 ./cli/app/ps.go:205 ./cli/app/secret.go:553 ./cli/app/secret.go:649 ./cli/recipe/list.go:104 ./cli/recipe/upgrade.go:376 ./cli/recipe/version.go:139 ./cli/run.go:152 ./cli/server/list.go:106 ./cli/updater/updater.go:560
msgid "m"
msgstr ""
@ -3434,12 +3460,12 @@ msgid "malformed version pin specification: %s"
msgstr ""
#. translators: `abra man` command for autocompletion
#: ./cli/run.go:74
#: ./cli/run.go:97
msgid "man"
msgstr ""
#. translators: `man` command
#: ./cli/run.go:132
#: ./cli/run.go:156
msgid "man [flags]"
msgstr ""
@ -3918,7 +3944,7 @@ msgstr ""
msgid "polling undeploy status"
msgstr ""
#: ./cli/run.go:185
#: ./cli/run.go:209
msgid "prefer offline & filesystem access"
msgstr ""
@ -4054,7 +4080,7 @@ msgid "readme: %s, "
msgstr ""
#. translators: `abra recipe` command for autocompletion
#: ./cli/app/list.go:302 ./cli/app/list.go:309 ./cli/run.go:76
#: ./cli/app/list.go:302 ./cli/app/list.go:309 ./cli/run.go:99
msgid "recipe"
msgstr ""
@ -4496,7 +4522,7 @@ msgid "secrets are %s shown again, please save them %s"
msgstr ""
#. translators: `abra server` command for autocompletion
#: ./cli/app/list.go:325 ./cli/app/list.go:332 ./cli/app/new.go:337 ./cli/app/new.go:344 ./cli/run.go:78
#: ./cli/app/list.go:325 ./cli/app/list.go:332 ./cli/app/new.go:337 ./cli/app/new.go:344 ./cli/run.go:101
msgid "server"
msgstr ""
@ -4612,7 +4638,7 @@ msgstr ""
msgid "show apps of a specific server"
msgstr ""
#: ./cli/run.go:169 ./cli/updater/updater.go:507
#: ./cli/run.go:193 ./cli/updater/updater.go:507
msgid "show debug messages"
msgstr ""
@ -4893,7 +4919,7 @@ msgstr ""
msgid "tmpfs options are incompatible with type volume"
msgstr ""
#: ./cli/run.go:177 ./cli/updater/updater.go:515
#: ./cli/run.go:201 ./cli/updater/updater.go:515
msgid "toggle non-interactive mode"
msgstr ""
@ -4977,7 +5003,7 @@ msgstr ""
msgid "unable to convert to JSON: %s"
msgstr ""
#: ./cli/run.go:94
#: ./cli/run.go:117
#, c-format
msgid "unable to create %s: %s"
msgstr ""
@ -5071,7 +5097,7 @@ msgstr ""
msgid "unable to parse '%s' value as bool: %s"
msgstr ""
#: ./cli/run.go:152
#: ./cli/run.go:176
#, c-format
msgid "unable to proceed, %s does not exist?"
msgstr ""
@ -5227,6 +5253,11 @@ msgstr ""
msgid "unknown deployed version, unable to upgrade"
msgstr ""
#: ./cli/run.go:60
#, c-format
msgid "unknown help topic %#q\n"
msgstr ""
#: ./pkg/upstream/convert/service.go:780
#, c-format
msgid "unknown mode: %s"
@ -5268,7 +5299,7 @@ msgid "updating %s to %s in %s"
msgstr ""
#. translators: `abra upgrade` command for autocompletion
#: ./cli/run.go:80
#: ./cli/run.go:103
msgid "upgrade"
msgstr ""
@ -5343,7 +5374,7 @@ msgstr ""
#. translators: `abra recipe versions` aliases. use a comma separated list of aliases
#. with no spaces in between
#: ./cli/app/backup.go:311 ./cli/app/restore.go:122 ./cli/recipe/version.go:19 ./cli/server/prune.go:107
#: ./cli/app/backup.go:311 ./cli/app/restore.go:122 ./cli/recipe/version.go:19 ./cli/run.go:223 ./cli/server/prune.go:107
msgid "v"
msgstr ""
@ -5371,6 +5402,10 @@ msgstr ""
msgid "vendor config versions in an abra.sh"
msgstr ""
#: ./cli/run.go:222
msgid "version"
msgstr ""
#: ./pkg/app/app.go:688
#, c-format
msgid "version %s saved to %s.env"
@ -5381,6 +5416,10 @@ msgstr ""
msgid "version : %s, "
msgstr ""
#: ./cli/run.go:225
msgid "version for abra"
msgstr ""
#: ./pkg/recipe/recipe.go:130
#, c-format
msgid "version seems invalid: %s"

View File

@ -2,7 +2,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: EMAIL\n"
"POT-Creation-Date: 2025-09-03 00:25+0200\n"
"POT-Creation-Date: 2025-09-03 08:57+0200\n"
"PO-Revision-Date: 2025-08-29 21:45+0000\n"
"Last-Translator: chasqui <chasqui@cryptolab.net>\n"
"Language-Team: Spanish <https://translate.coopcloud.tech/projects/co-op-"
@ -44,7 +44,7 @@ msgid ""
" abra recipe fetch gitea --ssh"
msgstr ""
#: cli/run.go:136
#: cli/run.go:160
msgid ""
" # generate the man pages into /usr/local/share/man/man1\n"
" abra_path=$(which abra) # pass abra absolute path to sudo below\n"
@ -926,7 +926,7 @@ msgid ""
msgstr ""
#. translators: Short description for `man` command
#: cli/run.go:135
#: cli/run.go:159
msgid "Generate manpage"
msgstr "📒 Manual de uso"
@ -956,6 +956,17 @@ msgstr ""
msgid "HOST"
msgstr ""
#. translators: Short description for `help` command
#: cli/run.go:54
msgid "Help about any command"
msgstr ""
#: cli/run.go:55
msgid ""
"Help provides help for any command in the application.\n"
"Simply type abra help [path to command] for full details."
msgstr ""
#: cli/app/ps.go:187 cli/recipe/version.go:69
msgid "IMAGE"
msgstr ""
@ -1406,14 +1417,14 @@ msgid "The Co-op Cloud auto-updater 🤖 🚀"
msgstr "📨 Actualizador automático de Co-op Cloud 🤖 🚀"
#. translators: Short description for `abra` binary
#: cli/run.go:57
#: cli/run.go:80
msgid "The Co-op Cloud command-line utility belt 🎩🐇"
msgstr "La varita de mágica de Co-op Cloud 🪄🎩🐇"
#. translators: Long description for `abra` binary. This needs to be
#. translated in the same way as the Short description so that everything
#. matches up
#: cli/run.go:61
#: cli/run.go:84
#, fuzzy, c-format
msgid ""
"The Co-op Cloud command-line utility belt 🎩🐇\n"
@ -1800,7 +1811,7 @@ msgid "aborting as requested"
msgstr ""
#. translators: `abra` binary name
#: cli/run.go:55
#: cli/run.go:78
msgid "abra [cmd] [args] [flags]"
msgstr ""
@ -1808,7 +1819,7 @@ msgstr ""
msgid "abra app labels 1312.net"
msgstr ""
#: cli/run.go:114
#: cli/run.go:137
#, c-format
msgid "abra version: %s, commit: %s, lang: %s"
msgstr ""
@ -1885,7 +1896,7 @@ msgid "ambiguous service list received, prompting for input"
msgstr ""
#. translators: `abra app` command for autocompletion
#: cli/run.go:68
#: cli/run.go:91
msgid "app"
msgstr "plataforma"
@ -1943,7 +1954,7 @@ msgid "attempting to scale %s to 1"
msgstr ""
#. translators: `abra autocomplete` command for autocompletion
#: cli/run.go:70
#: cli/run.go:93
msgid "autocomplete"
msgstr ""
@ -2126,7 +2137,7 @@ msgid "cannot use [version] and --latest together"
msgstr ""
#. translators: `abra catalogue` command for autocompletion
#: cli/run.go:72
#: cli/run.go:95
msgid "catalogue"
msgstr ""
@ -2623,7 +2634,7 @@ msgstr ""
msgid "domain name for app"
msgstr ""
#: cli/run.go:160
#: cli/run.go:184
msgid "don't forget to run 'sudo mandb'"
msgstr ""
@ -3250,6 +3261,10 @@ msgstr ""
msgid "git: opening repository in %s"
msgstr ""
#: cli/run.go:215
msgid "h"
msgstr ""
#: cli/recipe/new.go:94
msgid "happy hacking 🎉"
msgstr ""
@ -3266,6 +3281,19 @@ msgstr ""
msgid "healthcheck enabled for all services"
msgstr ""
#: cli/run.go:214
msgid "help"
msgstr ""
#: cli/run.go:52
#, fuzzy
msgid "help [command]"
msgstr "💻 Ejecutar comandos en una plataforma 🚀"
#: cli/run.go:217
msgid "help for abra"
msgstr ""
#: cli/app/restore.go:129
msgid "hooks"
msgstr ""
@ -3619,7 +3647,7 @@ msgstr "plataformas"
#. with no spaces in between
#: cli/app/list.go:318 cli/app/move.go:34 cli/app/ps.go:205
#: cli/app/secret.go:553 cli/app/secret.go:649 cli/recipe/list.go:104
#: cli/recipe/upgrade.go:376 cli/recipe/version.go:139 cli/run.go:128
#: cli/recipe/upgrade.go:376 cli/recipe/version.go:139 cli/run.go:152
#: cli/server/list.go:106 cli/updater/updater.go:560
msgid "m"
msgstr ""
@ -3647,12 +3675,12 @@ msgid "malformed version pin specification: %s"
msgstr ""
#. translators: `abra man` command for autocompletion
#: cli/run.go:74
#: cli/run.go:97
msgid "man"
msgstr ""
#. translators: `man` command
#: cli/run.go:132
#: cli/run.go:156
msgid "man [flags]"
msgstr "manual [flags]"
@ -4154,7 +4182,7 @@ msgstr ""
msgid "polling undeploy status"
msgstr "📋 Revisar el estado de una plataforma"
#: cli/run.go:185
#: cli/run.go:209
msgid "prefer offline & filesystem access"
msgstr ""
@ -4295,7 +4323,7 @@ msgid "readme: %s, "
msgstr ""
#. translators: `abra recipe` command for autocompletion
#: cli/app/list.go:302 cli/app/list.go:309 cli/run.go:76
#: cli/app/list.go:302 cli/app/list.go:309 cli/run.go:99
msgid "recipe"
msgstr ""
@ -4745,7 +4773,7 @@ msgstr ""
#. translators: `abra server` command for autocompletion
#: cli/app/list.go:325 cli/app/list.go:332 cli/app/new.go:337
#: cli/app/new.go:344 cli/run.go:78
#: cli/app/new.go:344 cli/run.go:101
msgid "server"
msgstr ""
@ -4863,7 +4891,7 @@ msgstr ""
msgid "show apps of a specific server"
msgstr ""
#: cli/run.go:169 cli/updater/updater.go:507
#: cli/run.go:193 cli/updater/updater.go:507
msgid "show debug messages"
msgstr ""
@ -5147,7 +5175,7 @@ msgstr ""
msgid "tmpfs options are incompatible with type volume"
msgstr ""
#: cli/run.go:177 cli/updater/updater.go:515
#: cli/run.go:201 cli/updater/updater.go:515
msgid "toggle non-interactive mode"
msgstr ""
@ -5232,7 +5260,7 @@ msgstr ""
msgid "unable to convert to JSON: %s"
msgstr ""
#: cli/run.go:94
#: cli/run.go:117
#, c-format
msgid "unable to create %s: %s"
msgstr ""
@ -5327,7 +5355,7 @@ msgstr ""
msgid "unable to parse '%s' value as bool: %s"
msgstr ""
#: cli/run.go:152
#: cli/run.go:176
#, c-format
msgid "unable to proceed, %s does not exist?"
msgstr ""
@ -5490,6 +5518,11 @@ msgstr ""
msgid "unknown deployed version, unable to upgrade"
msgstr ""
#: cli/run.go:60
#, c-format
msgid "unknown help topic %#q\n"
msgstr ""
#: pkg/upstream/convert/service.go:780
#, c-format
msgid "unknown mode: %s"
@ -5531,7 +5564,7 @@ msgid "updating %s to %s in %s"
msgstr ""
#. translators: `abra upgrade` command for autocompletion
#: cli/run.go:80
#: cli/run.go:103
msgid "upgrade"
msgstr ""
@ -5607,7 +5640,7 @@ msgstr ""
#. translators: `abra recipe versions` aliases. use a comma separated list of aliases
#. with no spaces in between
#: cli/app/backup.go:311 cli/app/restore.go:122 cli/recipe/version.go:19
#: cli/server/prune.go:107
#: cli/run.go:223 cli/server/prune.go:107
msgid "v"
msgstr ""
@ -5635,6 +5668,10 @@ msgstr ""
msgid "vendor config versions in an abra.sh"
msgstr ""
#: cli/run.go:222
msgid "version"
msgstr ""
#: pkg/app/app.go:688
#, c-format
msgid "version %s saved to %s.env"
@ -5645,6 +5682,10 @@ msgstr ""
msgid "version : %s, "
msgstr ""
#: cli/run.go:225
msgid "version for abra"
msgstr ""
#: pkg/recipe/recipe.go:130
#, c-format
msgid "version seems invalid: %s"