This commit is contained in:
2025-04-13 19:39:01 +03:00
parent 587abf7aad
commit f26b72b2a2
10 changed files with 186 additions and 184 deletions

View File

@ -92,6 +92,16 @@ func (b *AppBuilder) WithDB() *AppBuilder {
}
func (b *AppBuilder) WithRepos() *AppBuilder {
b.withRepos(false)
return b
}
func (b *AppBuilder) WithReposForcePull() *AppBuilder {
b.withRepos(true)
return b
}
func (b *AppBuilder) withRepos(forcePull bool) *AppBuilder {
if b.err != nil {
return b
}
@ -105,7 +115,7 @@ func (b *AppBuilder) WithRepos() *AppBuilder {
rs := repos.New(cfg, db)
if cfg.AutoPull() {
if forcePull || cfg.AutoPull() {
if err := rs.Pull(b.ctx, cfg.Repos()); err != nil {
slog.Error(gotext.Get("Error pulling repositories"), "err", err)
b.err = cli.Exit("", 1)

View File

@ -0,0 +1,48 @@
// ALR - Any Linux Repository
// Copyright (C) 2025 Евгений Храмов
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package cliutils
import (
"fmt"
"log/slog"
"github.com/urfave/cli/v2"
)
type BashCompleteWithErrorFunc func(c *cli.Context) error
func BashCompleteWithError(f BashCompleteWithErrorFunc) cli.BashCompleteFunc {
return func(c *cli.Context) { HandleExitCoder(f(c)) }
}
func HandleExitCoder(err error) {
if err == nil {
return
}
if exitErr, ok := err.(cli.ExitCoder); ok {
if err.Error() != "" {
if _, ok := exitErr.(cli.ErrorFormatter); ok {
slog.Error(fmt.Sprintf("%+v\n", err))
} else {
slog.Error(err.Error())
}
}
cli.OsExiter(exitErr.ExitCode())
return
}
}

View File

@ -122,47 +122,47 @@ msgstr ""
msgid "The directory that the install commands will install to"
msgstr ""
#: helper.go:73
#: helper.go:73 helper.go:74
msgid "No such helper command"
msgstr ""
#: info.go:44
msgid "Print information about a package"
msgstr ""
#: info.go:49
msgid "Show all information, not just for the current distro"
msgstr ""
#: info.go:75
msgid "Error getting packages"
msgstr ""
#: info.go:84
msgid "Error iterating over packages"
msgstr ""
#: info.go:98
msgid "Command info expected at least 1 argument, got %d"
msgstr ""
#: info.go:118
msgid "Error finding packages"
msgstr ""
#: info.go:134
msgid "Can't detect system language"
msgstr ""
#: info.go:144
#: helper.go:85
msgid "Error parsing os-release file"
msgstr ""
#: info.go:153
#: info.go:43
msgid "Print information about a package"
msgstr ""
#: info.go:48
msgid "Show all information, not just for the current distro"
msgstr ""
#: info.go:69
msgid "Error getting packages"
msgstr ""
#: info.go:78
msgid "Error iterating over packages"
msgstr ""
#: info.go:93
msgid "Command info expected at least 1 argument, got %d"
msgstr ""
#: info.go:113
msgid "Error finding packages"
msgstr ""
#: info.go:129
msgid "Can't detect system language"
msgstr ""
#: info.go:148
msgid "Error resolving overrides"
msgstr ""
#: info.go:162 info.go:168
#: info.go:157 info.go:163
msgid "Error encoding script variables"
msgstr ""
@ -315,7 +315,7 @@ msgstr ""
msgid "You need to be root to perform this action"
msgstr ""
#: list.go:41
#: list.go:40
msgid "List ALR repo packages"
msgstr ""
@ -323,19 +323,19 @@ msgstr ""
msgid "Print the current ALR version and exit"
msgstr ""
#: main.go:79
#: main.go:61
msgid "Arguments to be passed on to the package manager"
msgstr ""
#: main.go:85
#: main.go:67
msgid "Enable interactive questions and prompts"
msgstr ""
#: main.go:185
#: main.go:148
msgid "Show help"
msgstr ""
#: main.go:189
#: main.go:152
msgid "Error while running app"
msgstr ""
@ -419,51 +419,51 @@ msgid ""
"updating ALR if something doesn't work."
msgstr ""
#: repo.go:41
#: repo.go:42
msgid "Add a new repository"
msgstr ""
#: repo.go:48
#: repo.go:49
msgid "Name of the new repo"
msgstr ""
#: repo.go:54
#: repo.go:55
msgid "URL of the new repo"
msgstr ""
#: repo.go:92 repo.go:172
#: repo.go:93 repo.go:173
msgid "Error saving config"
msgstr ""
#: repo.go:97 repo.go:199
#: repo.go:98
msgid "Can't drop privileges"
msgstr ""
#: repo.go:104 repo.go:110 repo.go:219
#: repo.go:105 repo.go:111
msgid "Error pulling repos"
msgstr ""
#: repo.go:122
#: repo.go:123
msgid "Remove an existing repository"
msgstr ""
#: repo.go:129
#: repo.go:130
msgid "Name of the repo to be deleted"
msgstr ""
#: repo.go:158
#: repo.go:159
msgid "Repo does not exist"
msgstr ""
#: repo.go:166
#: repo.go:167
msgid "Error removing repo directory"
msgstr ""
#: repo.go:183
#: repo.go:184
msgid "Error removing packages from database"
msgstr ""
#: repo.go:195
#: repo.go:196
msgid "Pull all repositories that have changed"
msgstr ""

View File

@ -136,48 +136,48 @@ msgstr "Запустить вспомогательную команду ALR"
msgid "The directory that the install commands will install to"
msgstr "Каталог, в который будут устанавливать команды установки"
#: helper.go:73
#: helper.go:73 helper.go:74
msgid "No such helper command"
msgstr "Такой вспомогательной команды нет"
#: info.go:44
#: helper.go:85
msgid "Error parsing os-release file"
msgstr "Ошибка при разборе файла выпуска операционной системы"
#: info.go:43
msgid "Print information about a package"
msgstr "Отобразить информацию о пакете"
#: info.go:49
#: info.go:48
msgid "Show all information, not just for the current distro"
msgstr "Показывать всю информацию, не только для текущего дистрибутива"
#: info.go:75
#: info.go:69
msgid "Error getting packages"
msgstr "Ошибка при получении пакетов"
#: info.go:84
#: info.go:78
msgid "Error iterating over packages"
msgstr "Ошибка при переборе пакетов"
#: info.go:98
#: info.go:93
msgid "Command info expected at least 1 argument, got %d"
msgstr "Для команды info ожидался хотя бы 1 аргумент, получено %d"
#: info.go:118
#: info.go:113
msgid "Error finding packages"
msgstr "Ошибка при поиске пакетов"
#: info.go:134
#: info.go:129
#, fuzzy
msgid "Can't detect system language"
msgstr "Ошибка при парсинге языка системы"
#: info.go:144
msgid "Error parsing os-release file"
msgstr "Ошибка при разборе файла выпуска операционной системы"
#: info.go:153
#: info.go:148
msgid "Error resolving overrides"
msgstr "Ошибка устранения переорпеделений"
#: info.go:162 info.go:168
#: info.go:157 info.go:163
msgid "Error encoding script variables"
msgstr "Ошибка кодирования переменных скрита"
@ -331,7 +331,7 @@ msgstr "ОШИБКА"
msgid "You need to be root to perform this action"
msgstr ""
#: list.go:41
#: list.go:40
msgid "List ALR repo packages"
msgstr "Список пакетов репозитория ALR"
@ -339,19 +339,19 @@ msgstr "Список пакетов репозитория ALR"
msgid "Print the current ALR version and exit"
msgstr "Показать текущую версию ALR и выйти"
#: main.go:79
#: main.go:61
msgid "Arguments to be passed on to the package manager"
msgstr "Аргументы, которые будут переданы менеджеру пакетов"
#: main.go:85
#: main.go:67
msgid "Enable interactive questions and prompts"
msgstr "Включение интерактивных вопросов и запросов"
#: main.go:185
#: main.go:148
msgid "Show help"
msgstr "Показать справку"
#: main.go:189
#: main.go:152
msgid "Error while running app"
msgstr "Ошибка при запуске приложения"
@ -441,52 +441,52 @@ msgstr ""
"Минимальная версия ALR для ALR-репозитория выше текущей версии. Попробуйте "
"обновить ALR, если что-то не работает."
#: repo.go:41
#: repo.go:42
msgid "Add a new repository"
msgstr "Добавить новый репозиторий"
#: repo.go:48
#: repo.go:49
msgid "Name of the new repo"
msgstr "Название нового репозитория"
#: repo.go:54
#: repo.go:55
msgid "URL of the new repo"
msgstr "URL-адрес нового репозитория"
#: repo.go:92 repo.go:172
#: repo.go:93 repo.go:173
#, fuzzy
msgid "Error saving config"
msgstr "Ошибка при кодировании конфигурации"
#: repo.go:97 repo.go:199
#: repo.go:98
msgid "Can't drop privileges"
msgstr ""
#: repo.go:104 repo.go:110 repo.go:219
#: repo.go:105 repo.go:111
msgid "Error pulling repos"
msgstr "Ошибка при извлечении репозиториев"
#: repo.go:122
#: repo.go:123
msgid "Remove an existing repository"
msgstr "Удалить существующий репозиторий"
#: repo.go:129
#: repo.go:130
msgid "Name of the repo to be deleted"
msgstr "Название репозитория удалён"
#: repo.go:158
#: repo.go:159
msgid "Repo does not exist"
msgstr "Репозитория не существует"
#: repo.go:166
#: repo.go:167
msgid "Error removing repo directory"
msgstr "Ошибка при удалении каталога репозитория"
#: repo.go:183
#: repo.go:184
msgid "Error removing packages from database"
msgstr "Ошибка при удалении пакетов из базы данных"
#: repo.go:195
#: repo.go:196
msgid "Pull all repositories that have changed"
msgstr "Скачать все изменённые репозитории"