chore: make usage strings translatable

This commit is contained in:
Maxim Slipenko 2025-01-22 17:16:15 +03:00
parent b9bf908007
commit 30f95a4cbf
12 changed files with 789 additions and 584 deletions

@ -35,25 +35,26 @@ import (
"gitea.plemya-x.ru/Plemya-x/ALR/pkg/repos" "gitea.plemya-x.ru/Plemya-x/ALR/pkg/repos"
) )
var buildCmd = &cli.Command{ func BuildCmd() *cli.Command {
return &cli.Command{
Name: "build", Name: "build",
Usage: "Build a local package", Usage: gotext.Get("Build a local package"),
Flags: []cli.Flag{ Flags: []cli.Flag{
&cli.StringFlag{ &cli.StringFlag{
Name: "script", Name: "script",
Aliases: []string{"s"}, Aliases: []string{"s"},
Value: "alr.sh", Value: "alr.sh",
Usage: "Path to the build script", Usage: gotext.Get("Path to the build script"),
}, },
&cli.StringFlag{ &cli.StringFlag{
Name: "package", Name: "package",
Aliases: []string{"p"}, Aliases: []string{"p"},
Usage: "Name of the package to build and its repo (example: default/go-bin)", Usage: gotext.Get("Name of the package to build and its repo (example: default/go-bin)"),
}, },
&cli.BoolFlag{ &cli.BoolFlag{
Name: "clean", Name: "clean",
Aliases: []string{"c"}, Aliases: []string{"c"},
Usage: "Build package from scratch even if there's an already built package available", Usage: gotext.Get("Build package from scratch even if there's an already built package available"),
}, },
}, },
Action: func(c *cli.Context) error { Action: func(c *cli.Context) error {
@ -105,3 +106,4 @@ var buildCmd = &cli.Command{
return nil return nil
}, },
} }
}

6
fix.go

@ -31,9 +31,10 @@ import (
"gitea.plemya-x.ru/Plemya-x/ALR/pkg/repos" "gitea.plemya-x.ru/Plemya-x/ALR/pkg/repos"
) )
var fixCmd = &cli.Command{ func FixCmd() *cli.Command {
return &cli.Command{
Name: "fix", Name: "fix",
Usage: "Attempt to fix problems with ALR", Usage: gotext.Get("Attempt to fix problems with ALR"),
Action: func(c *cli.Context) error { Action: func(c *cli.Context) error {
ctx := c.Context ctx := c.Context
@ -67,3 +68,4 @@ var fixCmd = &cli.Command{
return nil return nil
}, },
} }
}

17
gen.go

@ -22,23 +22,21 @@ package main
import ( import (
"os" "os"
"github.com/leonelquinteros/gotext"
"github.com/urfave/cli/v2" "github.com/urfave/cli/v2"
"gitea.plemya-x.ru/Plemya-x/ALR/pkg/gen" "gitea.plemya-x.ru/Plemya-x/ALR/pkg/gen"
) )
var genCmd = &cli.Command{ func GenCmd() *cli.Command {
return &cli.Command{
Name: "generate", Name: "generate",
Usage: "Generate a ALR script from a template", Usage: gotext.Get("Generate a ALR script from a template"),
Aliases: []string{"gen"}, Aliases: []string{"gen"},
Subcommands: []*cli.Command{ Subcommands: []*cli.Command{
genPipCmd, &cli.Command{
},
}
var genPipCmd = &cli.Command{
Name: "pip", Name: "pip",
Usage: "Generate a ALR script for a pip module", Usage: gotext.Get("Generate a ALR script for a pip module"),
Flags: []cli.Flag{ Flags: []cli.Flag{
&cli.StringFlag{ &cli.StringFlag{
Name: "name", Name: "name",
@ -62,4 +60,7 @@ var genPipCmd = &cli.Command{
Description: c.String("description"), Description: c.String("description"),
}) })
}, },
},
},
}
} }

@ -35,16 +35,29 @@ import (
"gitea.plemya-x.ru/Plemya-x/ALR/pkg/distro" "gitea.plemya-x.ru/Plemya-x/ALR/pkg/distro"
) )
var helperCmd = &cli.Command{ func HelperCmd() *cli.Command {
var helperListCmd = &cli.Command{
Name: "list",
Usage: gotext.Get("List all the available helper commands"),
Aliases: []string{"ls"},
Action: func(ctx *cli.Context) error {
for name := range helpers.Helpers {
fmt.Println(name)
}
return nil
},
}
return &cli.Command{
Name: "helper", Name: "helper",
Usage: "Run a ALR helper command", Usage: gotext.Get("Run a ALR helper command"),
ArgsUsage: `<helper_name|"list">`, ArgsUsage: `<helper_name|"list">`,
Subcommands: []*cli.Command{helperListCmd}, Subcommands: []*cli.Command{helperListCmd},
Flags: []cli.Flag{ Flags: []cli.Flag{
&cli.StringFlag{ &cli.StringFlag{
Name: "dest-dir", Name: "dest-dir",
Aliases: []string{"d"}, Aliases: []string{"d"},
Usage: "The directory that the install commands will install to", Usage: gotext.Get("The directory that the install commands will install to"),
Value: "dest", Value: "dest",
}, },
}, },
@ -95,15 +108,4 @@ var helperCmd = &cli.Command{
} }
}, },
} }
var helperListCmd = &cli.Command{
Name: "list",
Usage: "List all the available helper commands",
Aliases: []string{"ls"},
Action: func(ctx *cli.Context) error {
for name := range helpers.Helpers {
fmt.Println(name)
}
return nil
},
} }

@ -36,7 +36,7 @@ import (
"gitea.plemya-x.ru/Plemya-x/ALR/pkg/repos" "gitea.plemya-x.ru/Plemya-x/ALR/pkg/repos"
) )
func GetInfoCmd() *cli.Command { func InfoCmd() *cli.Command {
return &cli.Command{ return &cli.Command{
Name: "info", Name: "info",
Usage: gotext.Get("Print information about a package"), Usage: gotext.Get("Print information about a package"),

@ -36,9 +36,11 @@ import (
"gitea.plemya-x.ru/Plemya-x/ALR/pkg/repos" "gitea.plemya-x.ru/Plemya-x/ALR/pkg/repos"
) )
var installCmd = &cli.Command{ func InstallCmd() *cli.Command {
return &cli.Command{
Name: "install", Name: "install",
Usage: "Install a new package", Usage: gotext.Get("Install a new package"),
Aliases: []string{"in"}, Aliases: []string{"in"},
Flags: []cli.Flag{ Flags: []cli.Flag{
&cli.BoolFlag{ &cli.BoolFlag{
@ -102,10 +104,12 @@ var installCmd = &cli.Command{
} }
}, },
} }
}
var removeCmd = &cli.Command{ func RemoveCmd() *cli.Command {
return &cli.Command{
Name: "remove", Name: "remove",
Usage: "Remove an installed package", Usage: gotext.Get("Remove an installed package"),
Aliases: []string{"rm"}, Aliases: []string{"rm"},
Action: func(c *cli.Context) error { Action: func(c *cli.Context) error {
args := c.Args() args := c.Args()
@ -129,3 +133,4 @@ var removeCmd = &cli.Command{
return nil return nil
}, },
} }
}

@ -9,51 +9,92 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: build.go:69 #: build.go:41
msgid "Build a local package"
msgstr ""
#: build.go:47
msgid "Path to the build script"
msgstr ""
#: build.go:52
msgid "Name of the package to build and its repo (example: default/go-bin)"
msgstr ""
#: build.go:57
msgid ""
"Build package from scratch even if there's an already built package available"
msgstr ""
#: build.go:70
msgid "Error pulling repositories" msgid "Error pulling repositories"
msgstr "" msgstr ""
#: build.go:75 #: build.go:76
msgid "Unable to detect a supported package manager on the system" msgid "Unable to detect a supported package manager on the system"
msgstr "" msgstr ""
#: build.go:86 #: build.go:87
msgid "Error building package" msgid "Error building package"
msgstr "" msgstr ""
#: build.go:92 #: build.go:93
msgid "Error getting working directory" msgid "Error getting working directory"
msgstr "" msgstr ""
#: build.go:100 #: build.go:101
msgid "Error moving the package" msgid "Error moving the package"
msgstr "" msgstr ""
#: fix.go:43 #: fix.go:37
msgid "Attempt to fix problems with ALR"
msgstr ""
#: fix.go:44
msgid "Removing cache directory" msgid "Removing cache directory"
msgstr "" msgstr ""
#: fix.go:47 #: fix.go:48
msgid "Unable to remove cache directory" msgid "Unable to remove cache directory"
msgstr "" msgstr ""
#: fix.go:51 #: fix.go:52
msgid "Rebuilding cache" msgid "Rebuilding cache"
msgstr "" msgstr ""
#: fix.go:55 #: fix.go:56
msgid "Unable to create new cache directory" msgid "Unable to create new cache directory"
msgstr "" msgstr ""
#: fix.go:61 #: fix.go:62
msgid "Error pulling repos" msgid "Error pulling repos"
msgstr "" msgstr ""
#: fix.go:65 #: fix.go:66
msgid "Done" msgid "Done"
msgstr "" msgstr ""
#: gen.go:34
msgid "Generate a ALR script from a template"
msgstr ""
#: gen.go:39
msgid "Generate a ALR script for a pip module"
msgstr ""
#: helper.go:41
msgid "List all the available helper commands"
msgstr ""
#: helper.go:53
msgid "Run a ALR helper command"
msgstr ""
#: helper.go:60 #: helper.go:60
msgid "The directory that the install commands will install to"
msgstr ""
#: helper.go:73
msgid "No such helper command" msgid "No such helper command"
msgstr "" msgstr ""
@ -85,23 +126,27 @@ msgstr ""
msgid "Error encoding script variables" msgid "Error encoding script variables"
msgstr "" msgstr ""
#: install.go:55 #: install.go:57
msgid "Command install expected at least 1 argument, got %d" msgid "Command install expected at least 1 argument, got %d"
msgstr "" msgstr ""
#: install.go:88 #: install.go:90
msgid "Error getting packages" msgid "Error getting packages"
msgstr "" msgstr ""
#: install.go:97 #: install.go:99
msgid "Error iterating over packages" msgid "Error iterating over packages"
msgstr "" msgstr ""
#: install.go:113 #: install.go:112
msgid "Remove an installed package"
msgstr ""
#: install.go:117
msgid "Command remove expected at least 1 argument, got %d" msgid "Command remove expected at least 1 argument, got %d"
msgstr "" msgstr ""
#: install.go:125 #: install.go:129
msgid "Error removing packages" msgid "Error removing packages"
msgstr "" msgstr ""
@ -202,21 +247,37 @@ msgstr ""
msgid "ERROR" msgid "ERROR"
msgstr "" msgstr ""
#: list.go:53 #: list.go:40
msgid "List ALR repo packages"
msgstr ""
#: list.go:54
msgid "Error initialization database" msgid "Error initialization database"
msgstr "" msgstr ""
#: list.go:87 #: list.go:88
msgid "Error listing installed packages" msgid "Error listing installed packages"
msgstr "" msgstr ""
#: main.go:88 #: main.go:45
msgid "Print the current ALR version and exit"
msgstr ""
#: main.go:61
msgid "Arguments to be passed on to the package manager"
msgstr ""
#: main.go:67
msgid "Enable interactive questions and prompts"
msgstr ""
#: main.go:90
msgid "" msgid ""
"Running ALR as root is forbidden as it may cause catastrophic damage to your " "Running ALR as root is forbidden as it may cause catastrophic damage to your "
"system" "system"
msgstr "" msgstr ""
#: main.go:122 #: main.go:124
msgid "Error while running app" msgid "Error while running app"
msgstr "" msgstr ""
@ -328,26 +389,54 @@ msgid ""
"updating ALR if something doesn't work." "updating ALR if something doesn't work."
msgstr "" msgstr ""
#: repo.go:78 repo.go:133 #: repo.go:41
msgid "Add a new repository"
msgstr ""
#: repo.go:48
msgid "Name of the new repo"
msgstr ""
#: repo.go:54
msgid "URL of the new repo"
msgstr ""
#: repo.go:79 repo.go:136
msgid "Error opening config file" msgid "Error opening config file"
msgstr "" msgstr ""
#: repo.go:84 repo.go:139 #: repo.go:85 repo.go:142
msgid "Error encoding config" msgid "Error encoding config"
msgstr "" msgstr ""
#: repo.go:125 #: repo.go:103
msgid "Remove an existing repository"
msgstr ""
#: repo.go:110
msgid "Name of the repo to be deleted"
msgstr ""
#: repo.go:128
msgid "Repo does not exist" msgid "Repo does not exist"
msgstr "" msgstr ""
#: repo.go:145 #: repo.go:148
msgid "Error removing repo directory" msgid "Error removing repo directory"
msgstr "" msgstr ""
#: repo.go:151 #: repo.go:154
msgid "Error removing packages from database" msgid "Error removing packages from database"
msgstr "" msgstr ""
#: upgrade.go:78 #: repo.go:166
msgid "Pull all repositories that have changed"
msgstr ""
#: upgrade.go:47
msgid "Upgrade all installed packages"
msgstr ""
#: upgrade.go:79
msgid "Error checking for updates" msgid "Error checking for updates"
msgstr "" msgstr ""

@ -11,55 +11,98 @@ msgstr ""
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && " "Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
"n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" "%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
"X-Generator: Gtranslator 47.1\n" "X-Generator: Gtranslator 47.1\n"
#: build.go:69 #: build.go:41
#, fuzzy
msgid "Build a local package"
msgstr "Сборка пакета"
#: build.go:47
#, fuzzy
msgid "Path to the build script"
msgstr "Не удалось предложить просмотреть скрипт"
#: build.go:52
msgid "Name of the package to build and its repo (example: default/go-bin)"
msgstr ""
#: build.go:57
msgid ""
"Build package from scratch even if there's an already built package available"
msgstr ""
#: build.go:70
msgid "Error pulling repositories" msgid "Error pulling repositories"
msgstr "" msgstr ""
#: build.go:75 #: build.go:76
msgid "Unable to detect a supported package manager on the system" msgid "Unable to detect a supported package manager on the system"
msgstr "" msgstr ""
#: build.go:86 #: build.go:87
msgid "Error building package" msgid "Error building package"
msgstr "Ошибка при сборке пакета" msgstr "Ошибка при сборке пакета"
#: build.go:92 #: build.go:93
msgid "Error getting working directory" msgid "Error getting working directory"
msgstr "" msgstr ""
#: build.go:100 #: build.go:101
msgid "Error moving the package" msgid "Error moving the package"
msgstr "" msgstr ""
#: fix.go:43 #: fix.go:37
msgid "Attempt to fix problems with ALR"
msgstr ""
#: fix.go:44
msgid "Removing cache directory" msgid "Removing cache directory"
msgstr "" msgstr ""
#: fix.go:47 #: fix.go:48
msgid "Unable to remove cache directory" msgid "Unable to remove cache directory"
msgstr "" msgstr ""
#: fix.go:51 #: fix.go:52
msgid "Rebuilding cache" msgid "Rebuilding cache"
msgstr "" msgstr ""
#: fix.go:55 #: fix.go:56
msgid "Unable to create new cache directory" msgid "Unable to create new cache directory"
msgstr "" msgstr ""
#: fix.go:61 #: fix.go:62
msgid "Error pulling repos" msgid "Error pulling repos"
msgstr "" msgstr ""
#: fix.go:65 #: fix.go:66
msgid "Done" msgid "Done"
msgstr "" msgstr ""
#: gen.go:34
msgid "Generate a ALR script from a template"
msgstr ""
#: gen.go:39
msgid "Generate a ALR script for a pip module"
msgstr ""
#: helper.go:41
msgid "List all the available helper commands"
msgstr ""
#: helper.go:53
msgid "Run a ALR helper command"
msgstr ""
#: helper.go:60 #: helper.go:60
msgid "The directory that the install commands will install to"
msgstr ""
#: helper.go:73
msgid "No such helper command" msgid "No such helper command"
msgstr "" msgstr ""
@ -91,23 +134,27 @@ msgstr ""
msgid "Error encoding script variables" msgid "Error encoding script variables"
msgstr "" msgstr ""
#: install.go:55 #: install.go:57
msgid "Command install expected at least 1 argument, got %d" msgid "Command install expected at least 1 argument, got %d"
msgstr "" msgstr ""
#: install.go:88 #: install.go:90
msgid "Error getting packages" msgid "Error getting packages"
msgstr "" msgstr ""
#: install.go:97 #: install.go:99
msgid "Error iterating over packages" msgid "Error iterating over packages"
msgstr "" msgstr ""
#: install.go:113 #: install.go:112
msgid "Remove an installed package"
msgstr ""
#: install.go:117
msgid "Command remove expected at least 1 argument, got %d" msgid "Command remove expected at least 1 argument, got %d"
msgstr "" msgstr ""
#: install.go:125 #: install.go:129
msgid "Error removing packages" msgid "Error removing packages"
msgstr "" msgstr ""
@ -208,21 +255,37 @@ msgstr "Скачивание источника"
msgid "ERROR" msgid "ERROR"
msgstr "ОШИБКА" msgstr "ОШИБКА"
#: list.go:53 #: list.go:40
msgid "List ALR repo packages"
msgstr ""
#: list.go:54
msgid "Error initialization database" msgid "Error initialization database"
msgstr "" msgstr ""
#: list.go:87 #: list.go:88
msgid "Error listing installed packages" msgid "Error listing installed packages"
msgstr "" msgstr ""
#: main.go:88 #: main.go:45
msgid "Print the current ALR version and exit"
msgstr ""
#: main.go:61
msgid "Arguments to be passed on to the package manager"
msgstr ""
#: main.go:67
msgid "Enable interactive questions and prompts"
msgstr ""
#: main.go:90
msgid "" msgid ""
"Running ALR as root is forbidden as it may cause catastrophic damage to your " "Running ALR as root is forbidden as it may cause catastrophic damage to your "
"system" "system"
msgstr "" msgstr ""
#: main.go:122 #: main.go:124
msgid "Error while running app" msgid "Error while running app"
msgstr "" msgstr ""
@ -334,26 +397,55 @@ msgid ""
"updating ALR if something doesn't work." "updating ALR if something doesn't work."
msgstr "" msgstr ""
#: repo.go:78 repo.go:133 #: repo.go:41
#, fuzzy
msgid "Add a new repository"
msgstr "Скачивание репозитория"
#: repo.go:48
msgid "Name of the new repo"
msgstr ""
#: repo.go:54
msgid "URL of the new repo"
msgstr ""
#: repo.go:79 repo.go:136
msgid "Error opening config file" msgid "Error opening config file"
msgstr "" msgstr ""
#: repo.go:84 repo.go:139 #: repo.go:85 repo.go:142
msgid "Error encoding config" msgid "Error encoding config"
msgstr "" msgstr ""
#: repo.go:125 #: repo.go:103
msgid "Remove an existing repository"
msgstr ""
#: repo.go:110
msgid "Name of the repo to be deleted"
msgstr ""
#: repo.go:128
msgid "Repo does not exist" msgid "Repo does not exist"
msgstr "" msgstr ""
#: repo.go:145 #: repo.go:148
msgid "Error removing repo directory" msgid "Error removing repo directory"
msgstr "" msgstr ""
#: repo.go:151 #: repo.go:154
msgid "Error removing packages from database" msgid "Error removing packages from database"
msgstr "" msgstr ""
#: upgrade.go:78 #: repo.go:166
msgid "Pull all repositories that have changed"
msgstr ""
#: upgrade.go:47
msgid "Upgrade all installed packages"
msgstr ""
#: upgrade.go:79
msgid "Error checking for updates" msgid "Error checking for updates"
msgstr "" msgstr ""

@ -34,9 +34,10 @@ import (
"gitea.plemya-x.ru/Plemya-x/ALR/pkg/repos" "gitea.plemya-x.ru/Plemya-x/ALR/pkg/repos"
) )
var listCmd = &cli.Command{ func ListCmd() *cli.Command {
return &cli.Command{
Name: "list", Name: "list",
Usage: "List ALR repo packages", Usage: gotext.Get("List ALR repo packages"),
Aliases: []string{"ls"}, Aliases: []string{"ls"},
Flags: []cli.Flag{ Flags: []cli.Flag{
&cli.BoolFlag{ &cli.BoolFlag{
@ -121,3 +122,4 @@ var listCmd = &cli.Command{
return nil return nil
}, },
} }
}

36
main.go

@ -39,14 +39,16 @@ import (
"gitea.plemya-x.ru/Plemya-x/ALR/internal/logger" "gitea.plemya-x.ru/Plemya-x/ALR/internal/logger"
) )
var versionCmd = &cli.Command{ func VersionCmd() *cli.Command {
return &cli.Command{
Name: "version", Name: "version",
Usage: "Print the current ALR version and exit", Usage: gotext.Get("Print the current ALR version and exit"),
Action: func(ctx *cli.Context) error { Action: func(ctx *cli.Context) error {
println(config.Version) println(config.Version)
return nil return nil
}, },
} }
}
func GetApp() *cli.App { func GetApp() *cli.App {
return &cli.App{ return &cli.App{
@ -56,29 +58,29 @@ func GetApp() *cli.App {
&cli.StringFlag{ &cli.StringFlag{
Name: "pm-args", Name: "pm-args",
Aliases: []string{"P"}, Aliases: []string{"P"},
Usage: "Arguments to be passed on to the package manager", Usage: gotext.Get("Arguments to be passed on to the package manager"),
}, },
&cli.BoolFlag{ &cli.BoolFlag{
Name: "interactive", Name: "interactive",
Aliases: []string{"i"}, Aliases: []string{"i"},
Value: isatty.IsTerminal(os.Stdin.Fd()), Value: isatty.IsTerminal(os.Stdin.Fd()),
Usage: "Enable interactive questions and prompts", Usage: gotext.Get("Enable interactive questions and prompts"),
}, },
}, },
Commands: []*cli.Command{ Commands: []*cli.Command{
installCmd, InstallCmd(),
removeCmd, RemoveCmd(),
upgradeCmd, UpgradeCmd(),
GetInfoCmd(), InfoCmd(),
listCmd, ListCmd(),
buildCmd, BuildCmd(),
addrepoCmd, AddRepoCmd(),
removerepoCmd, RemoveRepoCmd(),
refreshCmd, RefreshCmd(),
fixCmd, FixCmd(),
genCmd, GenCmd(),
helperCmd, HelperCmd(),
versionCmd, VersionCmd(),
}, },
Before: func(c *cli.Context) error { Before: func(c *cli.Context) error {
ctx := c.Context ctx := c.Context

24
repo.go

@ -35,22 +35,23 @@ import (
"gitea.plemya-x.ru/Plemya-x/ALR/pkg/repos" "gitea.plemya-x.ru/Plemya-x/ALR/pkg/repos"
) )
var addrepoCmd = &cli.Command{ func AddRepoCmd() *cli.Command {
return &cli.Command{
Name: "addrepo", Name: "addrepo",
Usage: "Add a new repository", Usage: gotext.Get("Add a new repository"),
Aliases: []string{"ar"}, Aliases: []string{"ar"},
Flags: []cli.Flag{ Flags: []cli.Flag{
&cli.StringFlag{ &cli.StringFlag{
Name: "name", Name: "name",
Aliases: []string{"n"}, Aliases: []string{"n"},
Required: true, Required: true,
Usage: "Name of the new repo", Usage: gotext.Get("Name of the new repo"),
}, },
&cli.StringFlag{ &cli.StringFlag{
Name: "url", Name: "url",
Aliases: []string{"u"}, Aliases: []string{"u"},
Required: true, Required: true,
Usage: "URL of the new repo", Usage: gotext.Get("URL of the new repo"),
}, },
}, },
Action: func(c *cli.Context) error { Action: func(c *cli.Context) error {
@ -94,17 +95,19 @@ var addrepoCmd = &cli.Command{
return nil return nil
}, },
} }
}
var removerepoCmd = &cli.Command{ func RemoveRepoCmd() *cli.Command {
return &cli.Command{
Name: "removerepo", Name: "removerepo",
Usage: "Remove an existing repository", Usage: gotext.Get("Remove an existing repository"),
Aliases: []string{"rr"}, Aliases: []string{"rr"},
Flags: []cli.Flag{ Flags: []cli.Flag{
&cli.StringFlag{ &cli.StringFlag{
Name: "name", Name: "name",
Aliases: []string{"n"}, Aliases: []string{"n"},
Required: true, Required: true,
Usage: "Name of the repo to be deleted", Usage: gotext.Get("Name of the repo to be deleted"),
}, },
}, },
Action: func(c *cli.Context) error { Action: func(c *cli.Context) error {
@ -155,10 +158,12 @@ var removerepoCmd = &cli.Command{
return nil return nil
}, },
} }
}
var refreshCmd = &cli.Command{ func RefreshCmd() *cli.Command {
return &cli.Command{
Name: "refresh", Name: "refresh",
Usage: "Pull all repositories that have changed", Usage: gotext.Get("Pull all repositories that have changed"),
Aliases: []string{"ref"}, Aliases: []string{"ref"},
Action: func(c *cli.Context) error { Action: func(c *cli.Context) error {
ctx := c.Context ctx := c.Context
@ -170,3 +175,4 @@ var refreshCmd = &cli.Command{
return nil return nil
}, },
} }
}

@ -41,15 +41,16 @@ import (
"gitea.plemya-x.ru/Plemya-x/ALR/pkg/repos" "gitea.plemya-x.ru/Plemya-x/ALR/pkg/repos"
) )
var upgradeCmd = &cli.Command{ func UpgradeCmd() *cli.Command {
return &cli.Command{
Name: "upgrade", Name: "upgrade",
Usage: "Upgrade all installed packages", Usage: gotext.Get("Upgrade all installed packages"),
Aliases: []string{"up"}, Aliases: []string{"up"},
Flags: []cli.Flag{ Flags: []cli.Flag{
&cli.BoolFlag{ &cli.BoolFlag{
Name: "clean", Name: "clean",
Aliases: []string{"c"}, Aliases: []string{"c"},
Usage: "Build package from scratch even if there's an already built package available", Usage: gotext.Get("Build package from scratch even if there's an already built package available"),
}, },
}, },
Action: func(c *cli.Context) error { Action: func(c *cli.Context) error {
@ -92,6 +93,7 @@ var upgradeCmd = &cli.Command{
return nil return nil
}, },
} }
}
func checkForUpdates(ctx context.Context, mgr manager.Manager, info *distro.OSRelease) ([]db.Package, error) { func checkForUpdates(ctx context.Context, mgr manager.Manager, info *distro.OSRelease) ([]db.Package, error) {
installed, err := mgr.ListInstalled(nil) installed, err := mgr.ListInstalled(nil)