feat: translation support
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
See #483
This commit is contained in:
@ -11,6 +11,7 @@ import (
|
||||
appPkg "coopcloud.tech/abra/pkg/app"
|
||||
"coopcloud.tech/abra/pkg/autocomplete"
|
||||
"coopcloud.tech/abra/pkg/formatter"
|
||||
"coopcloud.tech/abra/pkg/i18n"
|
||||
"coopcloud.tech/abra/pkg/log"
|
||||
"coopcloud.tech/tagcmp"
|
||||
"github.com/spf13/cobra"
|
||||
@ -39,20 +40,20 @@ type serverStatus struct {
|
||||
}
|
||||
|
||||
var AppListCommand = &cobra.Command{
|
||||
Use: "list [flags]",
|
||||
Aliases: []string{"ls"},
|
||||
Short: "List all managed apps",
|
||||
Long: `Generate a report of all managed apps.
|
||||
Use: i18n.G("list [flags]"),
|
||||
Aliases: []string{i18n.G("ls")},
|
||||
Short: i18n.G("List all managed apps"),
|
||||
Long: i18n.G(`Generate a report of all managed apps.
|
||||
|
||||
Use "--status/-S" flag to query all servers for the live deployment status.`,
|
||||
Example: ` # list apps of all servers without live status
|
||||
Use "--status/-S" flag to query all servers for the live deployment status.`),
|
||||
Example: i18n.G(` # list apps of all servers without live status
|
||||
abra app ls
|
||||
|
||||
# list apps of a specific server with live status
|
||||
abra app ls -s 1312.net -S
|
||||
|
||||
# list apps of all servers which match a specific recipe
|
||||
abra app ls -r gitea`,
|
||||
abra app ls -r gitea`),
|
||||
Args: cobra.NoArgs,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
appFiles, err := appPkg.LoadAppFiles(listAppServer)
|
||||
@ -107,11 +108,11 @@ Use "--status/-S" flag to query all servers for the live deployment status.`,
|
||||
totalAppsCount++
|
||||
|
||||
if status {
|
||||
status := "unknown"
|
||||
version := "unknown"
|
||||
chaos := "unknown"
|
||||
chaosVersion := "unknown"
|
||||
autoUpdate := "unknown"
|
||||
status := i18n.G("unknown")
|
||||
version := i18n.G("unknown")
|
||||
chaos := i18n.G("unknown")
|
||||
chaosVersion := i18n.G("unknown")
|
||||
autoUpdate := i18n.G("unknown")
|
||||
if statusMeta, ok := statuses[app.StackName()]; ok {
|
||||
if currentVersion, exists := statusMeta["version"]; exists {
|
||||
if currentVersion != "" {
|
||||
@ -144,12 +145,12 @@ Use "--status/-S" flag to query all servers for the live deployment status.`,
|
||||
var newUpdates []string
|
||||
if version != "unknown" && chaos == "false" {
|
||||
if err := app.Recipe.EnsureExists(); err != nil {
|
||||
log.Fatalf("unable to clone %s: %s", app.Name, err)
|
||||
log.Fatal(i18n.G("unable to clone %s: %s", app.Name, err))
|
||||
}
|
||||
|
||||
updates, err := app.Recipe.Tags()
|
||||
if err != nil {
|
||||
log.Fatalf("unable to retrieve tags for %s: %s", app.Name, err)
|
||||
log.Fatal(i18n.G("unable to retrieve tags for %s: %s", app.Name, err))
|
||||
}
|
||||
|
||||
parsedVersion, err := tagcmp.Parse(version)
|
||||
@ -171,9 +172,9 @@ Use "--status/-S" flag to query all servers for the live deployment status.`,
|
||||
|
||||
if len(newUpdates) == 0 {
|
||||
if version == "unknown" {
|
||||
appStats.Upgrade = "unknown"
|
||||
appStats.Upgrade = i18n.G("unknown")
|
||||
} else {
|
||||
appStats.Upgrade = "latest"
|
||||
appStats.Upgrade = i18n.G("latest")
|
||||
stats.LatestCount++
|
||||
}
|
||||
} else {
|
||||
@ -212,14 +213,15 @@ Use "--status/-S" flag to query all servers for the live deployment status.`,
|
||||
|
||||
serverStat := allStats[app.Server]
|
||||
|
||||
headers := []string{"RECIPE", "DOMAIN", "SERVER"}
|
||||
headers := []string{i18n.G("RECIPE"), i18n.G("DOMAIN"), i18n.G("SERVER")}
|
||||
if status {
|
||||
headers = append(headers, []string{
|
||||
"STATUS",
|
||||
"CHAOS",
|
||||
"VERSION",
|
||||
"UPGRADE",
|
||||
"AUTOUPDATE"}...,
|
||||
i18n.G("STATUS"),
|
||||
i18n.G("CHAOS"),
|
||||
i18n.G("VERSION"),
|
||||
i18n.G("UPGRADE"),
|
||||
i18n.G("AUTOUPDATE"),
|
||||
}...,
|
||||
)
|
||||
}
|
||||
|
||||
@ -283,22 +285,22 @@ var (
|
||||
func init() {
|
||||
AppListCommand.Flags().BoolVarP(
|
||||
&status,
|
||||
"status",
|
||||
"S",
|
||||
i18n.G("status"),
|
||||
i18n.G("S"),
|
||||
false,
|
||||
"show app deployment status",
|
||||
i18n.G("show app deployment status"),
|
||||
)
|
||||
|
||||
AppListCommand.Flags().StringVarP(
|
||||
&recipeFilter,
|
||||
"recipe",
|
||||
"r",
|
||||
i18n.G("recipe"),
|
||||
i18n.G("r"),
|
||||
"",
|
||||
"show apps of a specific recipe",
|
||||
i18n.G("show apps of a specific recipe"),
|
||||
)
|
||||
|
||||
AppListCommand.RegisterFlagCompletionFunc(
|
||||
"recipe",
|
||||
i18n.G("recipe"),
|
||||
func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
return autocomplete.RecipeNameComplete()
|
||||
},
|
||||
@ -306,22 +308,22 @@ func init() {
|
||||
|
||||
AppListCommand.Flags().BoolVarP(
|
||||
&internal.MachineReadable,
|
||||
"machine",
|
||||
"m",
|
||||
i18n.G("machine"),
|
||||
i18n.G("m"),
|
||||
false,
|
||||
"print machine-readable output",
|
||||
i18n.G("print machine-readable output"),
|
||||
)
|
||||
|
||||
AppListCommand.Flags().StringVarP(
|
||||
&listAppServer,
|
||||
"server",
|
||||
"s",
|
||||
i18n.G("server"),
|
||||
i18n.G("s"),
|
||||
"",
|
||||
"show apps of a specific server",
|
||||
i18n.G("show apps of a specific server"),
|
||||
)
|
||||
|
||||
AppListCommand.RegisterFlagCompletionFunc(
|
||||
"server",
|
||||
i18n.G("server"),
|
||||
func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
return autocomplete.ServerNameComplete()
|
||||
},
|
||||
|
Reference in New Issue
Block a user