This commit is contained in:
2025-04-13 19:54:04 +03:00
parent f26b72b2a2
commit b8cb7af3bb
14 changed files with 213 additions and 261 deletions

View File

@ -18,13 +18,13 @@ package main
import (
"fmt"
"log/slog"
"os"
"text/template"
"github.com/leonelquinteros/gotext"
"github.com/urfave/cli/v2"
"gitea.plemya-x.ru/Plemya-x/ALR/internal/cliutils"
appbuilder "gitea.plemya-x.ru/Plemya-x/ALR/internal/cliutils/app_builder"
"gitea.plemya-x.ru/Plemya-x/ALR/internal/utils"
"gitea.plemya-x.ru/Plemya-x/ALR/pkg/search"
@ -93,8 +93,7 @@ func SearchCmd() *cli.Command {
Build(),
)
if err != nil {
slog.Error(gotext.Get("Error while executing search"))
return cli.Exit(err, 1)
return cliutils.FormatCliExit(gotext.Get("Error while executing search"), err)
}
format := c.String("format")
@ -102,8 +101,7 @@ func SearchCmd() *cli.Command {
if format != "" {
tmpl, err = template.New("format").Parse(format)
if err != nil {
slog.Error(gotext.Get("Error parsing format template"))
return cli.Exit(err, 1)
return cliutils.FormatCliExit(gotext.Get("Error parsing format template"), err)
}
}
@ -111,8 +109,7 @@ func SearchCmd() *cli.Command {
if tmpl != nil {
err = tmpl.Execute(os.Stdout, dbPkg)
if err != nil {
slog.Error(gotext.Get("Error executing template"))
return cli.Exit(err, 1)
return cliutils.FormatCliExit(gotext.Get("Error executing template"), err)
}
fmt.Println()
} else {