refactor(i18n): use common.error.failed template for all error messages
Replace specific error keys with the generic template:
- common.error.working_dir -> common.error.failed + Action
- common.error.load_config -> common.error.failed + Action
- common.error.build_failed -> common.error.failed + Action
- common.error.get_logs -> common.error.failed + Action
- common.error.tests_failed -> common.error.failed + Action
This reduces 5 duplicate error keys to 1 reusable template:
"Failed to {{.Action}}"
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
3169728d3a
commit
bcf74fe84e
19 changed files with 47 additions and 52 deletions
|
|
@ -45,7 +45,7 @@ var taskCommitCmd = &cobra.Command{
|
||||||
|
|
||||||
cfg, err := agentic.LoadConfig("")
|
cfg, err := agentic.LoadConfig("")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%s: %w", i18n.T("common.error.load_config"), err)
|
return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "load config"}), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
client := agentic.NewClientFromConfig(cfg)
|
client := agentic.NewClientFromConfig(cfg)
|
||||||
|
|
@ -71,7 +71,7 @@ var taskCommitCmd = &cobra.Command{
|
||||||
// Get current directory
|
// Get current directory
|
||||||
cwd, err := os.Getwd()
|
cwd, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%s: %w", i18n.T("common.error.working_dir"), err)
|
return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get working directory"}), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for uncommitted changes
|
// Check for uncommitted changes
|
||||||
|
|
@ -116,7 +116,7 @@ var taskPRCmd = &cobra.Command{
|
||||||
|
|
||||||
cfg, err := agentic.LoadConfig("")
|
cfg, err := agentic.LoadConfig("")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%s: %w", i18n.T("common.error.load_config"), err)
|
return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "load config"}), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
client := agentic.NewClientFromConfig(cfg)
|
client := agentic.NewClientFromConfig(cfg)
|
||||||
|
|
@ -133,7 +133,7 @@ var taskPRCmd = &cobra.Command{
|
||||||
// Get current directory
|
// Get current directory
|
||||||
cwd, err := os.Getwd()
|
cwd, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%s: %w", i18n.T("common.error.working_dir"), err)
|
return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get working directory"}), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check current branch
|
// Check current branch
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ var tasksCmd = &cobra.Command{
|
||||||
|
|
||||||
cfg, err := agentic.LoadConfig("")
|
cfg, err := agentic.LoadConfig("")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%s: %w", i18n.T("common.error.load_config"), err)
|
return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "load config"}), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
client := agentic.NewClientFromConfig(cfg)
|
client := agentic.NewClientFromConfig(cfg)
|
||||||
|
|
@ -88,7 +88,7 @@ var taskCmd = &cobra.Command{
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
cfg, err := agentic.LoadConfig("")
|
cfg, err := agentic.LoadConfig("")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%s: %w", i18n.T("common.error.load_config"), err)
|
return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "load config"}), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
client := agentic.NewClientFromConfig(cfg)
|
client := agentic.NewClientFromConfig(cfg)
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ var taskUpdateCmd = &cobra.Command{
|
||||||
|
|
||||||
cfg, err := agentic.LoadConfig("")
|
cfg, err := agentic.LoadConfig("")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%s: %w", i18n.T("common.error.load_config"), err)
|
return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "load config"}), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
client := agentic.NewClientFromConfig(cfg)
|
client := agentic.NewClientFromConfig(cfg)
|
||||||
|
|
@ -75,7 +75,7 @@ var taskCompleteCmd = &cobra.Command{
|
||||||
|
|
||||||
cfg, err := agentic.LoadConfig("")
|
cfg, err := agentic.LoadConfig("")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%s: %w", i18n.T("common.error.load_config"), err)
|
return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "load config"}), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
client := agentic.NewClientFromConfig(cfg)
|
client := agentic.NewClientFromConfig(cfg)
|
||||||
|
|
|
||||||
|
|
@ -25,13 +25,13 @@ func runProjectBuild(buildType string, ciMode bool, targetsFlag string, outputDi
|
||||||
// Get current working directory as project root
|
// Get current working directory as project root
|
||||||
projectDir, err := os.Getwd()
|
projectDir, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%s: %w", i18n.T("common.error.working_dir"), err)
|
return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get working directory"}), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load configuration from .core/build.yaml (or defaults)
|
// Load configuration from .core/build.yaml (or defaults)
|
||||||
buildCfg, err := buildpkg.LoadConfig(projectDir)
|
buildCfg, err := buildpkg.LoadConfig(projectDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%s: %w", i18n.T("common.error.load_config"), err)
|
return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "load config"}), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Detect project type if not specified
|
// Detect project type if not specified
|
||||||
|
|
@ -120,7 +120,7 @@ func runProjectBuild(buildType string, ciMode bool, targetsFlag string, outputDi
|
||||||
artifacts, err := builder.Build(ctx, cfg, buildTargets)
|
artifacts, err := builder.Build(ctx, cfg, buildTargets)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !ciMode {
|
if !ciMode {
|
||||||
fmt.Printf("%s %s: %v\n", buildErrorStyle.Render(i18n.T("common.label.error")), i18n.T("common.error.build_failed"), err)
|
fmt.Printf("%s %s: %v\n", buildErrorStyle.Render(i18n.T("common.label.error")), i18n.T("common.error.failed", map[string]any{"Action": "build"}), err)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ func runBuildSDK(specPath, lang, version string, dryRun bool) error {
|
||||||
|
|
||||||
projectDir, err := os.Getwd()
|
projectDir, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%s: %w", i18n.T("common.error.working_dir"), err)
|
return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get working directory"}), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load config
|
// Load config
|
||||||
|
|
|
||||||
|
|
@ -12,13 +12,13 @@ import (
|
||||||
func runChangelog(fromRef, toRef string) error {
|
func runChangelog(fromRef, toRef string) error {
|
||||||
projectDir, err := os.Getwd()
|
projectDir, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%s: %w", i18n.T("common.error.working_dir"), err)
|
return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get working directory"}), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load config for changelog settings
|
// Load config for changelog settings
|
||||||
cfg, err := release.LoadConfig(projectDir)
|
cfg, err := release.LoadConfig(projectDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%s: %w", i18n.T("common.error.load_config"), err)
|
return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "load config"}), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate changelog
|
// Generate changelog
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ import (
|
||||||
func runCIReleaseInit() error {
|
func runCIReleaseInit() error {
|
||||||
projectDir, err := os.Getwd()
|
projectDir, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%s: %w", i18n.T("common.error.working_dir"), err)
|
return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get working directory"}), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if config already exists
|
// Check if config already exists
|
||||||
|
|
|
||||||
|
|
@ -17,13 +17,13 @@ func runCIPublish(dryRun bool, version string, draft, prerelease bool) error {
|
||||||
// Get current directory
|
// Get current directory
|
||||||
projectDir, err := os.Getwd()
|
projectDir, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%s: %w", i18n.T("common.error.working_dir"), err)
|
return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get working directory"}), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load configuration
|
// Load configuration
|
||||||
cfg, err := release.LoadConfig(projectDir)
|
cfg, err := release.LoadConfig(projectDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%s: %w", i18n.T("common.error.load_config"), err)
|
return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "load config"}), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply CLI overrides
|
// Apply CLI overrides
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ import (
|
||||||
func runCIReleaseVersion() error {
|
func runCIReleaseVersion() error {
|
||||||
projectDir, err := os.Getwd()
|
projectDir, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%s: %w", i18n.T("common.error.working_dir"), err)
|
return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get working directory"}), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
version, err := release.DetermineVersion(projectDir)
|
version, err := release.DetermineVersion(projectDir)
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ func addPHPBuildCommand(parent *cobra.Command) {
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
cwd, err := os.Getwd()
|
cwd, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%s: %w", i18n.T("common.error.working_dir"), err)
|
return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get working directory"}), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
@ -135,7 +135,7 @@ func runPHPBuildDocker(ctx context.Context, projectDir string, opts dockerBuildO
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
|
|
||||||
if err := phppkg.BuildDocker(ctx, buildOpts); err != nil {
|
if err := phppkg.BuildDocker(ctx, buildOpts); err != nil {
|
||||||
return fmt.Errorf("%s: %w", i18n.T("common.error.build_failed"), err)
|
return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "build"}), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("\n%s %s\n", successStyle.Render(i18n.T("common.label.done")), i18n.T("cmd.php.build.docker_success"))
|
fmt.Printf("\n%s %s\n", successStyle.Render(i18n.T("common.label.done")), i18n.T("cmd.php.build.docker_success"))
|
||||||
|
|
@ -173,7 +173,7 @@ func runPHPBuildLinuxKit(ctx context.Context, projectDir string, opts linuxKitBu
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
|
|
||||||
if err := phppkg.BuildLinuxKit(ctx, buildOpts); err != nil {
|
if err := phppkg.BuildLinuxKit(ctx, buildOpts); err != nil {
|
||||||
return fmt.Errorf("%s: %w", i18n.T("common.error.build_failed"), err)
|
return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "build"}), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("\n%s %s\n", successStyle.Render(i18n.T("common.label.done")), i18n.T("cmd.php.build.linuxkit_success"))
|
fmt.Printf("\n%s %s\n", successStyle.Render(i18n.T("common.label.done")), i18n.T("cmd.php.build.linuxkit_success"))
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ func addPHPDeployCommand(parent *cobra.Command) {
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
cwd, err := os.Getwd()
|
cwd, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%s: %w", i18n.T("common.error.working_dir"), err)
|
return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get working directory"}), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
env := phppkg.EnvProduction
|
env := phppkg.EnvProduction
|
||||||
|
|
@ -107,7 +107,7 @@ func addPHPDeployStatusCommand(parent *cobra.Command) {
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
cwd, err := os.Getwd()
|
cwd, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%s: %w", i18n.T("common.error.working_dir"), err)
|
return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get working directory"}), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
env := phppkg.EnvProduction
|
env := phppkg.EnvProduction
|
||||||
|
|
@ -156,7 +156,7 @@ func addPHPDeployRollbackCommand(parent *cobra.Command) {
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
cwd, err := os.Getwd()
|
cwd, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%s: %w", i18n.T("common.error.working_dir"), err)
|
return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get working directory"}), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
env := phppkg.EnvProduction
|
env := phppkg.EnvProduction
|
||||||
|
|
@ -216,7 +216,7 @@ func addPHPDeployListCommand(parent *cobra.Command) {
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
cwd, err := os.Getwd()
|
cwd, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%s: %w", i18n.T("common.error.working_dir"), err)
|
return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get working directory"}), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
env := phppkg.EnvProduction
|
env := phppkg.EnvProduction
|
||||||
|
|
|
||||||
|
|
@ -217,7 +217,7 @@ func runPHPLogs(service string, follow bool) error {
|
||||||
|
|
||||||
logsReader, err := server.Logs(service, follow)
|
logsReader, err := server.Logs(service, follow)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%s: %w", i18n.T("common.error.get_logs"), err)
|
return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get logs"}), err)
|
||||||
}
|
}
|
||||||
defer logsReader.Close()
|
defer logsReader.Close()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ func addPHPPackagesLinkCommand(parent *cobra.Command) {
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
cwd, err := os.Getwd()
|
cwd, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%s: %w", i18n.T("common.error.working_dir"), err)
|
return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get working directory"}), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("%s %s\n\n", dimStyle.Render(i18n.T("cmd.php.label.php")), i18n.T("cmd.php.packages.link.linking"))
|
fmt.Printf("%s %s\n\n", dimStyle.Render(i18n.T("cmd.php.label.php")), i18n.T("cmd.php.packages.link.linking"))
|
||||||
|
|
@ -58,7 +58,7 @@ func addPHPPackagesUnlinkCommand(parent *cobra.Command) {
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
cwd, err := os.Getwd()
|
cwd, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%s: %w", i18n.T("common.error.working_dir"), err)
|
return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get working directory"}), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("%s %s\n\n", dimStyle.Render(i18n.T("cmd.php.label.php")), i18n.T("cmd.php.packages.unlink.unlinking"))
|
fmt.Printf("%s %s\n\n", dimStyle.Render(i18n.T("cmd.php.label.php")), i18n.T("cmd.php.packages.unlink.unlinking"))
|
||||||
|
|
@ -83,7 +83,7 @@ func addPHPPackagesUpdateCommand(parent *cobra.Command) {
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
cwd, err := os.Getwd()
|
cwd, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%s: %w", i18n.T("common.error.working_dir"), err)
|
return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get working directory"}), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("%s %s\n\n", dimStyle.Render(i18n.T("cmd.php.label.php")), i18n.T("cmd.php.packages.update.updating"))
|
fmt.Printf("%s %s\n\n", dimStyle.Render(i18n.T("cmd.php.label.php")), i18n.T("cmd.php.packages.update.updating"))
|
||||||
|
|
@ -108,7 +108,7 @@ func addPHPPackagesListCommand(parent *cobra.Command) {
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
cwd, err := os.Getwd()
|
cwd, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%s: %w", i18n.T("common.error.working_dir"), err)
|
return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get working directory"}), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
packages, err := phppkg.ListLinkedPackages(cwd)
|
packages, err := phppkg.ListLinkedPackages(cwd)
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ func addPHPTestCommand(parent *cobra.Command) {
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
cwd, err := os.Getwd()
|
cwd, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%s: %w", i18n.T("common.error.working_dir"), err)
|
return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get working directory"}), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !phppkg.IsPHPProject(cwd) {
|
if !phppkg.IsPHPProject(cwd) {
|
||||||
|
|
@ -56,7 +56,7 @@ func addPHPTestCommand(parent *cobra.Command) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := phppkg.RunTests(ctx, opts); err != nil {
|
if err := phppkg.RunTests(ctx, opts); err != nil {
|
||||||
return fmt.Errorf("%s: %w", i18n.T("common.error.tests_failed"), err)
|
return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "run tests"}), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
@ -84,7 +84,7 @@ func addPHPFmtCommand(parent *cobra.Command) {
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
cwd, err := os.Getwd()
|
cwd, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%s: %w", i18n.T("common.error.working_dir"), err)
|
return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get working directory"}), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !phppkg.IsPHPProject(cwd) {
|
if !phppkg.IsPHPProject(cwd) {
|
||||||
|
|
@ -155,7 +155,7 @@ func addPHPAnalyseCommand(parent *cobra.Command) {
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
cwd, err := os.Getwd()
|
cwd, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%s: %w", i18n.T("common.error.working_dir"), err)
|
return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get working directory"}), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !phppkg.IsPHPProject(cwd) {
|
if !phppkg.IsPHPProject(cwd) {
|
||||||
|
|
@ -218,7 +218,7 @@ func addPHPPsalmCommand(parent *cobra.Command) {
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
cwd, err := os.Getwd()
|
cwd, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%s: %w", i18n.T("common.error.working_dir"), err)
|
return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get working directory"}), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !phppkg.IsPHPProject(cwd) {
|
if !phppkg.IsPHPProject(cwd) {
|
||||||
|
|
@ -283,7 +283,7 @@ func addPHPAuditCommand(parent *cobra.Command) {
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
cwd, err := os.Getwd()
|
cwd, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%s: %w", i18n.T("common.error.working_dir"), err)
|
return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get working directory"}), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !phppkg.IsPHPProject(cwd) {
|
if !phppkg.IsPHPProject(cwd) {
|
||||||
|
|
@ -376,7 +376,7 @@ func addPHPSecurityCommand(parent *cobra.Command) {
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
cwd, err := os.Getwd()
|
cwd, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%s: %w", i18n.T("common.error.working_dir"), err)
|
return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get working directory"}), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !phppkg.IsPHPProject(cwd) {
|
if !phppkg.IsPHPProject(cwd) {
|
||||||
|
|
@ -474,7 +474,7 @@ func addPHPQACommand(parent *cobra.Command) {
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
cwd, err := os.Getwd()
|
cwd, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%s: %w", i18n.T("common.error.working_dir"), err)
|
return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get working directory"}), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !phppkg.IsPHPProject(cwd) {
|
if !phppkg.IsPHPProject(cwd) {
|
||||||
|
|
@ -682,7 +682,7 @@ func addPHPRectorCommand(parent *cobra.Command) {
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
cwd, err := os.Getwd()
|
cwd, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%s: %w", i18n.T("common.error.working_dir"), err)
|
return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get working directory"}), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !phppkg.IsPHPProject(cwd) {
|
if !phppkg.IsPHPProject(cwd) {
|
||||||
|
|
@ -756,7 +756,7 @@ func addPHPInfectionCommand(parent *cobra.Command) {
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
cwd, err := os.Getwd()
|
cwd, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%s: %w", i18n.T("common.error.working_dir"), err)
|
return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get working directory"}), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !phppkg.IsPHPProject(cwd) {
|
if !phppkg.IsPHPProject(cwd) {
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ func init() {
|
||||||
func runSDKDiff(basePath, specPath string) error {
|
func runSDKDiff(basePath, specPath string) error {
|
||||||
projectDir, err := os.Getwd()
|
projectDir, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%s: %w", i18n.T("common.error.working_dir"), err)
|
return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get working directory"}), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Detect current spec if not provided
|
// Detect current spec if not provided
|
||||||
|
|
@ -106,7 +106,7 @@ func runSDKDiff(basePath, specPath string) error {
|
||||||
func runSDKValidate(specPath string) error {
|
func runSDKValidate(specPath string) error {
|
||||||
projectDir, err := os.Getwd()
|
projectDir, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%s: %w", i18n.T("common.error.working_dir"), err)
|
return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get working directory"}), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
s := sdkpkg.New(projectDir, &sdkpkg.Config{Spec: specPath})
|
s := sdkpkg.New(projectDir, &sdkpkg.Config{Spec: specPath})
|
||||||
|
|
|
||||||
|
|
@ -206,7 +206,7 @@ func runRegistrySetupWithReg(ctx context.Context, reg *repos.Registry, registryP
|
||||||
buildCmd.Stdout = os.Stdout
|
buildCmd.Stdout = os.Stdout
|
||||||
buildCmd.Stderr = os.Stderr
|
buildCmd.Stderr = os.Stderr
|
||||||
if err := buildCmd.Run(); err != nil {
|
if err := buildCmd.Run(); err != nil {
|
||||||
return fmt.Errorf("%s: %w", i18n.T("common.error.build_failed"), err)
|
return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "build"}), err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ func runTest(verbose, coverage, short bool, pkg, run string, race, jsonOutput bo
|
||||||
// JSON output for CI/agents
|
// JSON output for CI/agents
|
||||||
printJSONResults(results, exitCode)
|
printJSONResults(results, exitCode)
|
||||||
if exitCode != 0 {
|
if exitCode != 0 {
|
||||||
return fmt.Errorf(i18n.T("common.error.tests_failed"))
|
return fmt.Errorf(i18n.T("common.error.failed", map[string]any{"Action": "run tests"}))
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
@ -109,7 +109,7 @@ func runTest(verbose, coverage, short bool, pkg, run string, race, jsonOutput bo
|
||||||
|
|
||||||
if exitCode != 0 {
|
if exitCode != 0 {
|
||||||
fmt.Printf("\n%s %s\n", testFailStyle.Render(i18n.T("cli.fail")), i18n.T("cmd.test.tests_failed"))
|
fmt.Printf("\n%s %s\n", testFailStyle.Render(i18n.T("cli.fail")), i18n.T("cmd.test.tests_failed"))
|
||||||
return fmt.Errorf(i18n.T("common.error.tests_failed"))
|
return fmt.Errorf(i18n.T("common.error.failed", map[string]any{"Action": "run tests"}))
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("\n%s %s\n", testPassStyle.Render(i18n.T("cli.pass")), i18n.T("common.result.all_passed"))
|
fmt.Printf("\n%s %s\n", testPassStyle.Render(i18n.T("cli.pass")), i18n.T("common.result.all_passed"))
|
||||||
|
|
|
||||||
|
|
@ -302,7 +302,7 @@ func viewLogs(id string, follow bool) error {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
reader, err := manager.Logs(ctx, fullID, follow)
|
reader, err := manager.Logs(ctx, fullID, follow)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf(i18n.T("common.error.get_logs")+": %w", err)
|
return fmt.Errorf(i18n.T("common.error.failed", map[string]any{"Action": "get logs"})+": %w", err)
|
||||||
}
|
}
|
||||||
defer reader.Close()
|
defer reader.Close()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,12 +41,7 @@
|
||||||
"error": {
|
"error": {
|
||||||
"failed": "Failed to {{.Action}}",
|
"failed": "Failed to {{.Action}}",
|
||||||
"not_found": "{{.Item}} not found",
|
"not_found": "{{.Item}} not found",
|
||||||
"no_items": "No {{.Items}} found",
|
"no_items": "No {{.Items}} found"
|
||||||
"working_dir": "Failed to get working directory",
|
|
||||||
"load_config": "Failed to load config",
|
|
||||||
"build_failed": "Build failed",
|
|
||||||
"tests_failed": "Tests failed",
|
|
||||||
"get_logs": "Failed to get logs"
|
|
||||||
},
|
},
|
||||||
"success": {
|
"success": {
|
||||||
"completed": "{{.Action}} completed successfully",
|
"completed": "{{.Action}} completed successfully",
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue