forked from Vanilla-OS/apx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
72 lines (57 loc) · 1.75 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package main
/* License: GPLv3
Authors:
Mirko Brombin <[email protected]>
Pietro di Caprio <[email protected]>
Copyright: 2024
Description: Apx is a wrapper around multiple package managers to install packages and run commands inside a managed container.
*/
import (
"embed"
"os"
"github.com/vanilla-os/apx/v2/cmd"
"github.com/vanilla-os/apx/v2/core"
"github.com/vanilla-os/orchid/cmdr"
)
var Version = "development"
//go:embed locales/*.yml
var fs embed.FS
var apx *cmdr.App
func main() {
core.NewStandardApx()
apx = cmd.New(Version, fs)
// check if root, exit if so
if core.RootCheck(false) {
cmdr.Error.Println(apx.Trans("apx.errors.noRoot"))
os.Exit(1)
}
// root command
root := cmd.NewRootCommand(Version)
apx.CreateRootCommand(root, apx.Trans("apx.msg.help"), apx.Trans("apx.msg.version"))
msgs := cmdr.UsageStrings{
Usage: apx.Trans("apx.msg.usage"),
Aliases: apx.Trans("apx.msg.aliases"),
Examples: apx.Trans("apx.msg.examples"),
AvailableCommands: apx.Trans("apx.msg.availableCommands"),
AdditionalCommands: apx.Trans("apx.msg.additionalCommands"),
Flags: apx.Trans("apx.msg.flags"),
GlobalFlags: apx.Trans("apx.msg.globalFlags"),
AdditionalHelpTopics: apx.Trans("apx.msg.additionalHelpTopics"),
MoreInfo: apx.Trans("apx.msg.moreInfo"),
}
apx.SetUsageStrings(msgs)
// commands
stacks := cmd.NewStacksCommand()
root.AddCommand(stacks)
subsystems := cmd.NewSubSystemsCommand()
root.AddCommand(subsystems)
pkgManagers := cmd.NewPkgManagersCommand()
root.AddCommand(pkgManagers)
runtimeCmds := cmd.NewRuntimeCommands()
root.AddCommand(runtimeCmds...)
// run the app
err := apx.Run()
if err != nil {
cmdr.Error.Println(err)
}
}