chore: replace old logger with new
This commit is contained in:
		| @@ -21,16 +21,17 @@ package cliutils | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"log/slog" | ||||
| 	"os" | ||||
| 	"strings" | ||||
|  | ||||
| 	"github.com/AlecAivazis/survey/v2" | ||||
| 	"github.com/leonelquinteros/gotext" | ||||
|  | ||||
| 	"gitea.plemya-x.ru/Plemya-x/ALR/internal/config" | ||||
| 	"gitea.plemya-x.ru/Plemya-x/ALR/internal/db" | ||||
| 	"gitea.plemya-x.ru/Plemya-x/ALR/internal/pager" | ||||
| 	"gitea.plemya-x.ru/Plemya-x/ALR/internal/translations" | ||||
| 	"gitea.plemya-x.ru/Plemya-x/ALR/pkg/loggerctx" | ||||
| ) | ||||
|  | ||||
| // YesNoPrompt asks the user a yes or no question, using def as the default answer | ||||
| @@ -54,8 +55,6 @@ func YesNoPrompt(ctx context.Context, msg string, interactive, def bool) (bool, | ||||
| // shows it if they answer yes, then asks if they'd still like to | ||||
| // continue, and exits if they answer no. | ||||
| func PromptViewScript(ctx context.Context, script, name, style string, interactive bool) error { | ||||
| 	log := loggerctx.From(ctx) | ||||
|  | ||||
| 	if !interactive { | ||||
| 		return nil | ||||
| 	} | ||||
| @@ -78,7 +77,8 @@ func PromptViewScript(ctx context.Context, script, name, style string, interacti | ||||
| 		} | ||||
|  | ||||
| 		if !cont { | ||||
| 			log.Fatal(translations.Translator(ctx).TranslateTo("User chose not to continue after reading script", config.Language(ctx))).Send() | ||||
| 			slog.Error(gotext.Get("User chose not to continue after reading script")) | ||||
| 			os.Exit(1) | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| @@ -106,13 +106,13 @@ func ShowScript(path, name, style string) error { | ||||
| // FlattenPkgs attempts to flatten the a map of slices of packages into a single slice | ||||
| // of packages by prompting the user if multiple packages match. | ||||
| func FlattenPkgs(ctx context.Context, found map[string][]db.Package, verb string, interactive bool) []db.Package { | ||||
| 	log := loggerctx.From(ctx) | ||||
| 	var outPkgs []db.Package | ||||
| 	for _, pkgs := range found { | ||||
| 		if len(pkgs) > 1 && interactive { | ||||
| 			choice, err := PkgPrompt(ctx, pkgs, verb, interactive) | ||||
| 			if err != nil { | ||||
| 				log.Fatal("Error prompting for choice of package").Send() | ||||
| 				slog.Error(gotext.Get("Error prompting for choice of package")) | ||||
| 				os.Exit(1) | ||||
| 			} | ||||
| 			outPkgs = append(outPkgs, choice) | ||||
| 		} else if len(pkgs) == 1 || !interactive { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user