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:
@ -8,6 +8,7 @@ import (
|
||||
"coopcloud.tech/abra/pkg/autocomplete"
|
||||
"coopcloud.tech/abra/pkg/client"
|
||||
"coopcloud.tech/abra/pkg/formatter"
|
||||
"coopcloud.tech/abra/pkg/i18n"
|
||||
"coopcloud.tech/abra/pkg/log"
|
||||
"coopcloud.tech/abra/pkg/upstream/stack"
|
||||
"github.com/AlecAivazis/survey/v2"
|
||||
@ -15,9 +16,9 @@ import (
|
||||
)
|
||||
|
||||
var AppVolumeListCommand = &cobra.Command{
|
||||
Use: "list <domain> [flags]",
|
||||
Aliases: []string{"ls"},
|
||||
Short: "List volumes associated with an app",
|
||||
Use: i18n.G("list <domain> [flags]"),
|
||||
Aliases: []string{i18n.G("ls")},
|
||||
Short: i18n.G("List volumes associated with an app"),
|
||||
Args: cobra.ExactArgs(1),
|
||||
ValidArgsFunction: func(
|
||||
cmd *cobra.Command,
|
||||
@ -43,7 +44,7 @@ var AppVolumeListCommand = &cobra.Command{
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
headers := []string{"NAME", "ON SERVER"}
|
||||
headers := []string{i18n.G("NAME"), i18n.G("ON SERVER")}
|
||||
|
||||
table, err := formatter.CreateTable()
|
||||
if err != nil {
|
||||
@ -67,14 +68,14 @@ var AppVolumeListCommand = &cobra.Command{
|
||||
return
|
||||
}
|
||||
|
||||
log.Warnf("no volumes created for %s", app.Name)
|
||||
log.Warn(i18n.G("no volumes created for %s", app.Name))
|
||||
},
|
||||
}
|
||||
|
||||
var AppVolumeRemoveCommand = &cobra.Command{
|
||||
Use: "remove <domain> [volume] [flags]",
|
||||
Short: "Remove volume(s) associated with an app",
|
||||
Long: `Remove volumes associated with an app.
|
||||
Use: i18n.G("remove <domain> [volume] [flags]"),
|
||||
Short: i18n.G("Remove volume(s) associated with an app"),
|
||||
Long: i18n.G(`Remove volumes associated with an app.
|
||||
|
||||
The app in question must be undeployed before you try to remove volumes. See
|
||||
"abra app undeploy <domain>" for more.
|
||||
@ -83,13 +84,13 @@ The command is interactive and will show a multiple select input which allows
|
||||
you to make a seclection. Use the "?" key to see more help on navigating this
|
||||
interface.
|
||||
|
||||
Passing "--force/-f" will select all volumes for removal. Be careful.`,
|
||||
Example: ` # delete volumes interactively
|
||||
Passing "--force/-f" will select all volumes for removal. Be careful.`),
|
||||
Example: i18n.G(` # delete volumes interactively
|
||||
abra app volume rm 1312.net
|
||||
|
||||
# delete specific volume
|
||||
abra app volume rm 1312.net my_volume`,
|
||||
Aliases: []string{"rm"},
|
||||
abra app volume rm 1312.net my_volume`),
|
||||
Aliases: []string{i18n.G("rm")},
|
||||
Args: cobra.MinimumNArgs(1),
|
||||
ValidArgsFunction: func(
|
||||
cmd *cobra.Command,
|
||||
@ -116,7 +117,7 @@ Passing "--force/-f" will select all volumes for removal. Be careful.`,
|
||||
}
|
||||
|
||||
if deployMeta.IsDeployed {
|
||||
log.Fatalf("%s is still deployed. Run \"abra app undeploy %s\"", app.Name, app.Name)
|
||||
log.Fatal(i18n.G("%s is still deployed. Run \"abra app undeploy %s\"", app.Name, app.Name))
|
||||
}
|
||||
|
||||
filters, err := app.Filters(false, true)
|
||||
@ -141,15 +142,15 @@ Passing "--force/-f" will select all volumes for removal. Be careful.`,
|
||||
}
|
||||
|
||||
if !exactMatch {
|
||||
log.Fatalf("unable to remove volume: no volume with name '%s'?", volumeToDelete)
|
||||
log.Fatal(i18n.G("unable to remove volume: no volume with name '%s'?", volumeToDelete))
|
||||
}
|
||||
|
||||
err := client.RemoveVolumes(cl, context.Background(), []string{fullVolumeToDeleteName}, internal.Force, 5)
|
||||
if err != nil {
|
||||
log.Fatalf("removing volume %s failed: %s", volumeToDelete, err)
|
||||
log.Fatal(i18n.G("removing volume %s failed: %s", volumeToDelete, err))
|
||||
}
|
||||
|
||||
log.Infof("volume %s removed successfully", volumeToDelete)
|
||||
log.Info(i18n.G("volume %s removed successfully", volumeToDelete))
|
||||
|
||||
return
|
||||
}
|
||||
@ -157,8 +158,8 @@ Passing "--force/-f" will select all volumes for removal. Be careful.`,
|
||||
var volumesToRemove []string
|
||||
if !internal.Force && !internal.NoInput {
|
||||
volumesPrompt := &survey.MultiSelect{
|
||||
Message: "which volumes do you want to remove?",
|
||||
Help: "'x' indicates selected, enter / return to confirm, ctrl-c to exit, vim mode is enabled",
|
||||
Message: i18n.G("which volumes do you want to remove?"),
|
||||
Help: i18n.G("'x' indicates selected, enter / return to confirm, ctrl-c to exit, vim mode is enabled"),
|
||||
VimMode: true,
|
||||
Options: volumeNames,
|
||||
Default: volumeNames,
|
||||
@ -175,28 +176,28 @@ Passing "--force/-f" will select all volumes for removal. Be careful.`,
|
||||
if len(volumesToRemove) > 0 {
|
||||
err := client.RemoveVolumes(cl, context.Background(), volumesToRemove, internal.Force, 5)
|
||||
if err != nil {
|
||||
log.Fatalf("removing volumes failed: %s", err)
|
||||
log.Fatal(i18n.G("removing volumes failed: %s", err))
|
||||
}
|
||||
|
||||
log.Infof("%d volumes removed successfully", len(volumesToRemove))
|
||||
log.Info(i18n.G("%d volumes removed successfully", len(volumesToRemove)))
|
||||
} else {
|
||||
log.Info("no volumes removed")
|
||||
log.Info(i18n.G("no volumes removed"))
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
var AppVolumeCommand = &cobra.Command{
|
||||
Use: "volume [cmd] [args] [flags]",
|
||||
Aliases: []string{"vl"},
|
||||
Short: "Manage app volumes",
|
||||
Use: i18n.G("volume [cmd] [args] [flags]"),
|
||||
Aliases: []string{i18n.G("vl")},
|
||||
Short: i18n.G("Manage app volumes"),
|
||||
}
|
||||
|
||||
func init() {
|
||||
AppVolumeRemoveCommand.Flags().BoolVarP(
|
||||
&internal.Force,
|
||||
"force",
|
||||
"f",
|
||||
i18n.G("force"),
|
||||
i18n.G("f"),
|
||||
false,
|
||||
"perform action without further prompt",
|
||||
i18n.G("perform action without further prompt"),
|
||||
)
|
||||
}
|
||||
|
Reference in New Issue
Block a user