update config module

This commit is contained in:
2025-03-22 12:58:10 +03:00
parent 5e7d4033e4
commit 8f4b021a93
30 changed files with 437 additions and 375 deletions

View File

@ -20,15 +20,14 @@
package config
import (
"context"
"log/slog"
"os"
"path/filepath"
"sync"
"github.com/pelletier/go-toml/v2"
"reflect"
"github.com/caarlos0/env"
"github.com/leonelquinteros/gotext"
"github.com/pelletier/go-toml/v2"
"gitea.plemya-x.ru/Plemya-x/ALR/internal/types"
)
@ -36,9 +35,6 @@ import (
type ALRConfig struct {
cfg *types.Config
paths *Paths
cfgOnce sync.Once
pathsOnce sync.Once
}
var defaultConfig = &types.Config{
@ -53,147 +49,146 @@ func New() *ALRConfig {
return &ALRConfig{}
}
func (c *ALRConfig) Load(ctx context.Context) {
cfgFl, err := os.Open(c.GetPaths(ctx).ConfigPath)
func readConfig(path string) (*types.Config, error) {
file, err := os.Open(path)
if err != nil {
slog.Warn(gotext.Get("Error opening config file, using defaults"), "err", err)
c.cfg = defaultConfig
return
return nil, err
}
defer cfgFl.Close()
defer file.Close()
// Copy the default configuration into config
defCopy := *defaultConfig
config := &defCopy
config.Repos = nil
config := types.Config{}
err = toml.NewDecoder(cfgFl).Decode(config)
if err != nil {
slog.Warn(gotext.Get("Error decoding config file, using defaults"), "err", err)
c.cfg = defaultConfig
return
if err := toml.NewDecoder(file).Decode(&config); err != nil {
return nil, err
}
c.cfg = config
return &config, nil
}
func (c *ALRConfig) initPaths() {
paths := &Paths{}
func mergeStructs(dst, src interface{}) {
srcVal := reflect.ValueOf(src)
if srcVal.IsNil() {
return
}
srcVal = srcVal.Elem()
dstVal := reflect.ValueOf(dst).Elem()
for i := range srcVal.NumField() {
srcField := srcVal.Field(i)
srcFieldName := srcVal.Type().Field(i).Name
dstField := dstVal.FieldByName(srcFieldName)
if dstField.IsValid() && dstField.CanSet() {
dstField.Set(srcField)
}
}
}
const systemConfigPath = "/etc/alr/alr.toml"
func (c *ALRConfig) Load() error {
systemConfig, err := readConfig(
systemConfigPath,
)
if err != nil {
slog.Debug("Cannot read system config", "err", err)
}
cfgDir, err := os.UserConfigDir()
if err != nil {
slog.Error(gotext.Get("Unable to detect user config directory"), "err", err)
os.Exit(1)
slog.Debug("Cannot read user config directory")
}
userConfigPath := filepath.Join(cfgDir, "alr", "alr.toml")
paths.ConfigDir = filepath.Join(cfgDir, "alr")
err = os.MkdirAll(paths.ConfigDir, 0o755)
userConfig, err := readConfig(
userConfigPath,
)
if err != nil {
slog.Error(gotext.Get("Unable to create ALR config directory"), "err", err)
os.Exit(1)
slog.Debug("Cannot read user config")
}
paths.ConfigPath = filepath.Join(paths.ConfigDir, "alr.toml")
config := &types.Config{}
if _, err := os.Stat(paths.ConfigPath); err != nil {
cfgFl, err := os.Create(paths.ConfigPath)
if err != nil {
slog.Error(gotext.Get("Unable to create ALR config file"), "err", err)
os.Exit(1)
}
err = toml.NewEncoder(cfgFl).Encode(&defaultConfig)
if err != nil {
slog.Error(gotext.Get("Error encoding default configuration"), "err", err)
os.Exit(1)
}
cfgFl.Close()
mergeStructs(config, defaultConfig)
mergeStructs(config, systemConfig)
mergeStructs(config, userConfig)
err = env.Parse(config)
if err != nil {
return err
}
c.cfg = config
cacheDir, err := os.UserCacheDir()
if err != nil {
slog.Error(gotext.Get("Unable to detect cache directory"), "err", err)
os.Exit(1)
return err
}
c.paths = &Paths{}
c.paths.UserConfigPath = userConfigPath
c.paths.CacheDir = filepath.Join(cacheDir, "alr")
c.paths.RepoDir = filepath.Join(c.paths.CacheDir, "repo")
c.paths.PkgsDir = filepath.Join(c.paths.CacheDir, "pkgs")
c.paths.DBPath = filepath.Join(c.paths.CacheDir, "db")
c.initPaths()
paths.CacheDir = filepath.Join(cacheDir, "alr")
paths.RepoDir = filepath.Join(paths.CacheDir, "repo")
paths.PkgsDir = filepath.Join(paths.CacheDir, "pkgs")
return nil
}
err = os.MkdirAll(paths.RepoDir, 0o755)
func (c *ALRConfig) RootCmd() string {
return c.cfg.RootCmd
}
func (c *ALRConfig) PagerStyle() string {
return c.cfg.PagerStyle
}
func (c *ALRConfig) AutoPull() bool {
return c.cfg.AutoPull
}
func (c *ALRConfig) AllowRunAsRoot() bool {
return c.cfg.Unsafe.AllowRunAsRoot
}
func (c *ALRConfig) Repos() []types.Repo {
return c.cfg.Repos
}
func (c *ALRConfig) SetRepos(repos []types.Repo) {
c.cfg.Repos = repos
}
func (c *ALRConfig) IgnorePkgUpdates() []string {
return c.cfg.IgnorePkgUpdates
}
func (c *ALRConfig) LogLevel() string {
return c.cfg.LogLevel
}
func (c *ALRConfig) GetPaths() *Paths {
return c.paths
}
func (c *ALRConfig) initPaths() {
err := os.MkdirAll(c.paths.RepoDir, 0o755)
if err != nil {
slog.Error(gotext.Get("Unable to create repo cache directory"), "err", err)
os.Exit(1)
}
err = os.MkdirAll(paths.PkgsDir, 0o755)
err = os.MkdirAll(c.paths.PkgsDir, 0o755)
if err != nil {
slog.Error(gotext.Get("Unable to create package cache directory"), "err", err)
os.Exit(1)
}
paths.DBPath = filepath.Join(paths.CacheDir, "db")
c.paths = paths
}
func (c *ALRConfig) GetPaths(ctx context.Context) *Paths {
c.pathsOnce.Do(func() {
c.initPaths()
})
return c.paths
}
func (c *ALRConfig) SaveUserConfig() error {
f, err := os.Create(c.paths.UserConfigPath)
if err != nil {
return err
}
func (c *ALRConfig) Repos(ctx context.Context) []types.Repo {
c.cfgOnce.Do(func() {
c.Load(ctx)
})
return c.cfg.Repos
}
func (c *ALRConfig) SetRepos(ctx context.Context, repos []types.Repo) {
c.cfgOnce.Do(func() {
c.Load(ctx)
})
c.cfg.Repos = repos
}
func (c *ALRConfig) IgnorePkgUpdates(ctx context.Context) []string {
c.cfgOnce.Do(func() {
c.Load(ctx)
})
return c.cfg.IgnorePkgUpdates
}
func (c *ALRConfig) AutoPull(ctx context.Context) bool {
c.cfgOnce.Do(func() {
c.Load(ctx)
})
return c.cfg.AutoPull
}
func (c *ALRConfig) PagerStyle(ctx context.Context) string {
c.cfgOnce.Do(func() {
c.Load(ctx)
})
return c.cfg.PagerStyle
}
func (c *ALRConfig) AllowRunAsRoot(ctx context.Context) bool {
c.cfgOnce.Do(func() {
c.Load(ctx)
})
return c.cfg.Unsafe.AllowRunAsRoot
}
func (c *ALRConfig) RootCmd(ctx context.Context) string {
c.cfgOnce.Do(func() {
c.Load(ctx)
})
return c.cfg.RootCmd
}
func (c *ALRConfig) Save(f *os.File) error {
return toml.NewEncoder(f).Encode(c.cfg)
}

View File

@ -21,10 +21,9 @@ package config
// Paths contains various paths used by ALR
type Paths struct {
ConfigDir string
ConfigPath string
CacheDir string
RepoDir string
PkgsDir string
DBPath string
UserConfigPath string
CacheDir string
RepoDir string
PkgsDir string
DBPath string
}

View File

@ -59,7 +59,7 @@ type version struct {
}
type Config interface {
GetPaths(ctx context.Context) *config.Paths
GetPaths() *config.Paths
}
type Database struct {
@ -82,7 +82,7 @@ func (d *Database) Init(ctx context.Context) error {
}
func (d *Database) Connect(ctx context.Context) error {
dsn := d.config.GetPaths(ctx).DBPath
dsn := d.config.GetPaths().DBPath
db, err := sqlx.Open("sqlite", dsn)
if err != nil {
return err

View File

@ -33,7 +33,7 @@ import (
type TestALRConfig struct{}
func (c *TestALRConfig) GetPaths(ctx context.Context) *config.Paths {
func (c *TestALRConfig) GetPaths() *config.Paths {
return &config.Paths{
DBPath: ":memory:",
}

View File

@ -38,7 +38,7 @@ import (
type TestALRConfig struct{}
func (c *TestALRConfig) GetPaths(ctx context.Context) *config.Paths {
func (c *TestALRConfig) GetPaths() *config.Paths {
return &config.Paths{
CacheDir: "/tmp",
}

View File

@ -28,7 +28,7 @@ import (
)
type Config interface {
GetPaths(ctx context.Context) *config.Paths
GetPaths() *config.Paths
}
type DownloadCache struct {
@ -43,7 +43,7 @@ func New(cfg Config) *DownloadCache {
func (dc *DownloadCache) BasePath(ctx context.Context) string {
return filepath.Join(
dc.cfg.GetPaths(ctx).CacheDir, "dl",
dc.cfg.GetPaths().CacheDir, "dl",
)
}

View File

@ -36,7 +36,7 @@ type TestALRConfig struct {
CacheDir string
}
func (c *TestALRConfig) GetPaths(ctx context.Context) *config.Paths {
func (c *TestALRConfig) GetPaths() *config.Paths {
return &config.Paths{
CacheDir: c.CacheDir,
}

View File

@ -62,6 +62,25 @@ func New() *Logger {
}
}
func slogLevelToLog(level slog.Level) log.Level {
switch level {
case slog.LevelDebug:
return log.DebugLevel
case slog.LevelInfo:
return log.InfoLevel
case slog.LevelWarn:
return log.WarnLevel
case slog.LevelError:
return log.ErrorLevel
}
return log.FatalLevel
}
func (l *Logger) SetLevel(level slog.Level) {
l.lOut.(*log.Logger).SetLevel(slogLevelToLog(level))
l.lErr.(*log.Logger).SetLevel(slogLevelToLog(level))
}
func (l *Logger) Enabled(ctx context.Context, level slog.Level) bool {
if level <= slog.LevelInfo {
return l.lOut.Enabled(ctx, level)
@ -90,7 +109,9 @@ func (l *Logger) WithGroup(name string) slog.Handler {
return &sl
}
func SetupDefault() {
logger := slog.New(New())
func SetupDefault() *Logger {
l := New()
logger := slog.New(l)
slog.SetDefault(logger)
return l
}

View File

@ -30,35 +30,39 @@ msgid ""
"Build package from scratch even if there's an already built package available"
msgstr ""
#: build.go:75
#: build.go:73
msgid "Error loading config"
msgstr ""
#: build.go:81
msgid "Error initialization database"
msgstr ""
#: build.go:104
#: build.go:110
msgid "Package not found"
msgstr ""
#: build.go:124
#: build.go:130
msgid "Error pulling repositories"
msgstr ""
#: build.go:132
#: build.go:138
msgid "Unable to detect a supported package manager on the system"
msgstr ""
#: build.go:138
#: build.go:144
msgid "Error parsing os release"
msgstr ""
#: build.go:160
#: build.go:166
msgid "Error building package"
msgstr ""
#: build.go:167
#: build.go:173
msgid "Error getting working directory"
msgstr ""
#: build.go:176
#: build.go:182
msgid "Error moving the package"
msgstr ""
@ -66,27 +70,27 @@ msgstr ""
msgid "Attempt to fix problems with ALR"
msgstr ""
#: fix.go:43
#: fix.go:49
msgid "Removing cache directory"
msgstr ""
#: fix.go:47
#: fix.go:53
msgid "Unable to remove cache directory"
msgstr ""
#: fix.go:51
#: fix.go:57
msgid "Rebuilding cache"
msgstr ""
#: fix.go:55
#: fix.go:61
msgid "Unable to create new cache directory"
msgstr ""
#: fix.go:69
#: fix.go:81
msgid "Error pulling repos"
msgstr ""
#: fix.go:73
#: fix.go:85
msgid "Done"
msgstr ""
@ -122,31 +126,31 @@ msgstr ""
msgid "Show all information, not just for the current distro"
msgstr ""
#: info.go:63
#: info.go:69
msgid "Error getting packages"
msgstr ""
#: info.go:72
#: info.go:78
msgid "Error iterating over packages"
msgstr ""
#: info.go:93
#: info.go:105
msgid "Command info expected at least 1 argument, got %d"
msgstr ""
#: info.go:107
#: info.go:119
msgid "Error finding packages"
msgstr ""
#: info.go:132
#: info.go:144
msgid "Error parsing os-release file"
msgstr ""
#: info.go:141
#: info.go:153
msgid "Error resolving overrides"
msgstr ""
#: info.go:150 info.go:156
#: info.go:162 info.go:168
msgid "Error encoding script variables"
msgstr ""
@ -158,15 +162,15 @@ msgstr ""
msgid "Command install expected at least 1 argument, got %d"
msgstr ""
#: install.go:151
#: install.go:157
msgid "Remove an installed package"
msgstr ""
#: install.go:156
#: install.go:162
msgid "Command remove expected at least 1 argument, got %d"
msgstr ""
#: install.go:168
#: install.go:174
msgid "Error removing packages"
msgstr ""
@ -250,39 +254,11 @@ msgstr ""
msgid "OPTIONS"
msgstr ""
#: internal/config/config.go:59
msgid "Error opening config file, using defaults"
msgstr ""
#: internal/config/config.go:72
msgid "Error decoding config file, using defaults"
msgstr ""
#: internal/config/config.go:84
msgid "Unable to detect user config directory"
msgstr ""
#: internal/config/config.go:92
msgid "Unable to create ALR config directory"
msgstr ""
#: internal/config/config.go:101
msgid "Unable to create ALR config file"
msgstr ""
#: internal/config/config.go:107
msgid "Error encoding default configuration"
msgstr ""
#: internal/config/config.go:116
msgid "Unable to detect cache directory"
msgstr ""
#: internal/config/config.go:126
#: internal/config/config.go:176
msgid "Unable to create repo cache directory"
msgstr ""
#: internal/config/config.go:132
#: internal/config/config.go:182
msgid "Unable to create package cache directory"
msgstr ""
@ -327,7 +303,7 @@ msgstr ""
msgid "List ALR repo packages"
msgstr ""
#: list.go:92
#: list.go:98
msgid "Error listing installed packages"
msgstr ""
@ -343,17 +319,17 @@ msgstr ""
msgid "Enable interactive questions and prompts"
msgstr ""
#: main.go:92
#: main.go:96
msgid ""
"Running ALR as root is forbidden as it may cause catastrophic damage to your "
"system"
msgstr ""
#: main.go:125
#: main.go:154
msgid "Show help"
msgstr ""
#: main.go:129
#: main.go:158
msgid "Error while running app"
msgstr ""
@ -461,47 +437,43 @@ msgid ""
"updating ALR if something doesn't work."
msgstr ""
#: repo.go:41
#: repo.go:40
msgid "Add a new repository"
msgstr ""
#: repo.go:48
#: repo.go:47
msgid "Name of the new repo"
msgstr ""
#: repo.go:54
#: repo.go:53
msgid "URL of the new repo"
msgstr ""
#: repo.go:82 repo.go:147
msgid "Error opening config file"
#: repo.go:86 repo.go:151
msgid "Error saving config"
msgstr ""
#: repo.go:88 repo.go:153 repo.go:165
msgid "Error encoding config"
msgstr ""
#: repo.go:113
#: repo.go:111
msgid "Remove an existing repository"
msgstr ""
#: repo.go:120
#: repo.go:118
msgid "Name of the repo to be deleted"
msgstr ""
#: repo.go:139
#: repo.go:137
msgid "Repo does not exist"
msgstr ""
#: repo.go:159
#: repo.go:145
msgid "Error removing repo directory"
msgstr ""
#: repo.go:176
#: repo.go:162
msgid "Error removing packages from database"
msgstr ""
#: repo.go:188
#: repo.go:174
msgid "Pull all repositories that have changed"
msgstr ""
@ -529,11 +501,11 @@ msgstr ""
msgid "Format output using a Go template"
msgstr ""
#: search.go:82 search.go:99
#: search.go:88 search.go:105
msgid "Error parsing format template"
msgstr ""
#: search.go:107
#: search.go:113
msgid "Error executing template"
msgstr ""
@ -541,10 +513,10 @@ msgstr ""
msgid "Upgrade all installed packages"
msgstr ""
#: upgrade.go:90
#: upgrade.go:96
msgid "Error checking for updates"
msgstr ""
#: upgrade.go:112
#: upgrade.go:118
msgid "There is nothing to do."
msgstr ""

View File

@ -37,35 +37,40 @@ msgid ""
"Build package from scratch even if there's an already built package available"
msgstr "Создайте пакет с нуля, даже если уже имеется готовый пакет"
#: build.go:75
#: build.go:73
#, fuzzy
msgid "Error loading config"
msgstr "Ошибка при кодировании конфигурации"
#: build.go:81
msgid "Error initialization database"
msgstr "Ошибка инициализации базы данных"
#: build.go:104
#: build.go:110
msgid "Package not found"
msgstr "Пакет не найден"
#: build.go:124
#: build.go:130
msgid "Error pulling repositories"
msgstr "Ошибка при извлечении репозиториев"
#: build.go:132
#: build.go:138
msgid "Unable to detect a supported package manager on the system"
msgstr "Не удалось обнаружить поддерживаемый менеджер пакетов в системе"
#: build.go:138
#: build.go:144
msgid "Error parsing os release"
msgstr "Ошибка при разборе файла выпуска операционной системы"
#: build.go:160
#: build.go:166
msgid "Error building package"
msgstr "Ошибка при сборке пакета"
#: build.go:167
#: build.go:173
msgid "Error getting working directory"
msgstr "Ошибка при получении рабочего каталога"
#: build.go:176
#: build.go:182
msgid "Error moving the package"
msgstr "Ошибка при перемещении пакета"
@ -73,27 +78,27 @@ msgstr "Ошибка при перемещении пакета"
msgid "Attempt to fix problems with ALR"
msgstr "Попытка устранить проблемы с ALR"
#: fix.go:43
#: fix.go:49
msgid "Removing cache directory"
msgstr "Удаление каталога кэша"
#: fix.go:47
#: fix.go:53
msgid "Unable to remove cache directory"
msgstr "Не удалось удалить каталог кэша"
#: fix.go:51
#: fix.go:57
msgid "Rebuilding cache"
msgstr "Восстановление кэша"
#: fix.go:55
#: fix.go:61
msgid "Unable to create new cache directory"
msgstr "Не удалось создать новый каталог кэша"
#: fix.go:69
#: fix.go:81
msgid "Error pulling repos"
msgstr "Ошибка при извлечении репозиториев"
#: fix.go:73
#: fix.go:85
msgid "Done"
msgstr "Сделано"
@ -129,31 +134,31 @@ msgstr "Отобразить информацию о пакете"
msgid "Show all information, not just for the current distro"
msgstr "Показывать всю информацию, не только для текущего дистрибутива"
#: info.go:63
#: info.go:69
msgid "Error getting packages"
msgstr "Ошибка при получении пакетов"
#: info.go:72
#: info.go:78
msgid "Error iterating over packages"
msgstr "Ошибка при переборе пакетов"
#: info.go:93
#: info.go:105
msgid "Command info expected at least 1 argument, got %d"
msgstr "Для команды info ожидался хотя бы 1 аргумент, получено %d"
#: info.go:107
#: info.go:119
msgid "Error finding packages"
msgstr "Ошибка при поиске пакетов"
#: info.go:132
#: info.go:144
msgid "Error parsing os-release file"
msgstr "Ошибка при разборе файла выпуска операционной системы"
#: info.go:141
#: info.go:153
msgid "Error resolving overrides"
msgstr "Ошибка устранения переорпеделений"
#: info.go:150 info.go:156
#: info.go:162 info.go:168
msgid "Error encoding script variables"
msgstr "Ошибка кодирования переменных скрита"
@ -165,15 +170,15 @@ msgstr "Установить новый пакет"
msgid "Command install expected at least 1 argument, got %d"
msgstr "Для команды install ожидался хотя бы 1 аргумент, получено %d"
#: install.go:151
#: install.go:157
msgid "Remove an installed package"
msgstr "Удалить установленный пакет"
#: install.go:156
#: install.go:162
msgid "Command remove expected at least 1 argument, got %d"
msgstr "Для команды remove ожидался хотя бы 1 аргумент, получено %d"
#: install.go:168
#: install.go:174
msgid "Error removing packages"
msgstr "Ошибка при удалении пакетов"
@ -257,43 +262,11 @@ msgstr "КАТЕГОРИЯ"
msgid "OPTIONS"
msgstr "ПАРАМЕТРЫ"
#: internal/config/config.go:59
msgid "Error opening config file, using defaults"
msgstr ""
"Ошибка при открытии конфигурационного файла, используются значения по "
"умолчанию"
#: internal/config/config.go:72
msgid "Error decoding config file, using defaults"
msgstr ""
"Ошибка при декодировании конфигурационного файла, используются значения по "
"умолчанию"
#: internal/config/config.go:84
msgid "Unable to detect user config directory"
msgstr "Не удалось обнаружить каталог конфигурации пользователя"
#: internal/config/config.go:92
msgid "Unable to create ALR config directory"
msgstr "Не удалось создать каталог конфигурации ALR"
#: internal/config/config.go:101
msgid "Unable to create ALR config file"
msgstr "Не удалось создать конфигурационный файл ALR"
#: internal/config/config.go:107
msgid "Error encoding default configuration"
msgstr "Ошибка кодирования конфигурации по умолчанию"
#: internal/config/config.go:116
msgid "Unable to detect cache directory"
msgstr "Не удалось обнаружить каталог кэша"
#: internal/config/config.go:126
#: internal/config/config.go:176
msgid "Unable to create repo cache directory"
msgstr "Не удалось создать каталог кэша репозитория"
#: internal/config/config.go:132
#: internal/config/config.go:182
msgid "Unable to create package cache directory"
msgstr "Не удалось создать каталог кэша пакетов"
@ -339,7 +312,7 @@ msgstr "ОШИБКА"
msgid "List ALR repo packages"
msgstr "Список пакетов репозитория ALR"
#: list.go:92
#: list.go:98
msgid "Error listing installed packages"
msgstr "Ошибка при составлении списка установленных пакетов"
@ -355,7 +328,7 @@ msgstr "Аргументы, которые будут переданы мене
msgid "Enable interactive questions and prompts"
msgstr "Включение интерактивных вопросов и запросов"
#: main.go:92
#: main.go:96
msgid ""
"Running ALR as root is forbidden as it may cause catastrophic damage to your "
"system"
@ -363,11 +336,11 @@ msgstr ""
"Запуск ALR от имени root запрещён, так как это может привести к "
"катастрофическому повреждению вашей системы"
#: main.go:125
#: main.go:154
msgid "Show help"
msgstr "Показать справку"
#: main.go:129
#: main.go:158
msgid "Error while running app"
msgstr "Ошибка при запуске приложения"
@ -481,47 +454,44 @@ msgstr ""
"Минимальная версия ALR для ALR-репозитория выше текущей версии. Попробуйте "
"обновить ALR, если что-то не работает."
#: repo.go:41
#: repo.go:40
msgid "Add a new repository"
msgstr "Добавить новый репозиторий"
#: repo.go:48
#: repo.go:47
msgid "Name of the new repo"
msgstr "Название нового репозитория"
#: repo.go:54
#: repo.go:53
msgid "URL of the new repo"
msgstr "URL-адрес нового репозитория"
#: repo.go:82 repo.go:147
msgid "Error opening config file"
msgstr "Ошибка при открытии конфигурационного файла"
#: repo.go:88 repo.go:153 repo.go:165
msgid "Error encoding config"
#: repo.go:86 repo.go:151
#, fuzzy
msgid "Error saving config"
msgstr "Ошибка при кодировании конфигурации"
#: repo.go:113
#: repo.go:111
msgid "Remove an existing repository"
msgstr "Удалить существующий репозиторий"
#: repo.go:120
#: repo.go:118
msgid "Name of the repo to be deleted"
msgstr "Название репозитория удалён"
#: repo.go:139
#: repo.go:137
msgid "Repo does not exist"
msgstr "Репозитория не существует"
#: repo.go:159
#: repo.go:145
msgid "Error removing repo directory"
msgstr "Ошибка при удалении каталога репозитория"
#: repo.go:176
#: repo.go:162
msgid "Error removing packages from database"
msgstr "Ошибка при удалении пакетов из базы данных"
#: repo.go:188
#: repo.go:174
msgid "Pull all repositories that have changed"
msgstr "Скачать все изменённые репозитории"
@ -549,11 +519,11 @@ msgstr "Иcкать по provides"
msgid "Format output using a Go template"
msgstr "Формат выходных данных с использованием шаблона Go"
#: search.go:82 search.go:99
#: search.go:88 search.go:105
msgid "Error parsing format template"
msgstr "Ошибка при разборе шаблона"
#: search.go:107
#: search.go:113
msgid "Error executing template"
msgstr "Ошибка при выполнении шаблона"
@ -561,14 +531,42 @@ msgstr "Ошибка при выполнении шаблона"
msgid "Upgrade all installed packages"
msgstr "Обновить все установленные пакеты"
#: upgrade.go:90
#: upgrade.go:96
msgid "Error checking for updates"
msgstr "Ошибка при проверке обновлений"
#: upgrade.go:112
#: upgrade.go:118
msgid "There is nothing to do."
msgstr "Здесь нечего делать."
#~ msgid "Error opening config file, using defaults"
#~ msgstr ""
#~ "Ошибка при открытии конфигурационного файла, используются значения по "
#~ "умолчанию"
#~ msgid "Error decoding config file, using defaults"
#~ msgstr ""
#~ "Ошибка при декодировании конфигурационного файла, используются значения "
#~ "по умолчанию"
#~ msgid "Unable to detect user config directory"
#~ msgstr "Не удалось обнаружить каталог конфигурации пользователя"
#~ msgid "Unable to create ALR config directory"
#~ msgstr "Не удалось создать каталог конфигурации ALR"
#~ msgid "Unable to create ALR config file"
#~ msgstr "Не удалось создать конфигурационный файл ALR"
#~ msgid "Error encoding default configuration"
#~ msgstr "Ошибка кодирования конфигурации по умолчанию"
#~ msgid "Unable to detect cache directory"
#~ msgstr "Не удалось обнаружить каталог кэша"
#~ msgid "Error opening config file"
#~ msgstr "Ошибка при открытии конфигурационного файла"
#~ msgid "Error parsing system language"
#~ msgstr "Ошибка при парсинге языка системы"

View File

@ -21,12 +21,13 @@ package types
// Config represents the ALR configuration file
type Config struct {
RootCmd string `toml:"rootCmd"`
PagerStyle string `toml:"pagerStyle"`
RootCmd string `toml:"rootCmd" env:"ALR_ROOT_CMD"`
PagerStyle string `toml:"pagerStyle" env:"ALR_PAGER_STYLE"`
IgnorePkgUpdates []string `toml:"ignorePkgUpdates"`
Repos []Repo `toml:"repo"`
Unsafe Unsafe `toml:"unsafe"`
AutoPull bool `toml:"autoPull"`
AutoPull bool `toml:"autoPull" env:"ALR_AUTOPULL"`
LogLevel string `toml:"logLevel" env:"ALR_LOG_LEVEL"`
}
// Repo represents a ALR repo within a configuration file
@ -36,5 +37,5 @@ type Repo struct {
}
type Unsafe struct {
AllowRunAsRoot bool `toml:"allowRunAsRoot"`
AllowRunAsRoot bool `toml:"allowRunAsRoot" env:"ALR_UNSAFE_ALLOW_RUN_AS_ROOT"`
}