-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.go
More file actions
66 lines (53 loc) · 1.49 KB
/
main.go
File metadata and controls
66 lines (53 loc) · 1.49 KB
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
package main
import (
"os"
"strings"
"github.com/alecthomas/kong"
"github.com/aserto-dev/ds-load/cli/pkg/app"
"github.com/aserto-dev/ds-load/cli/pkg/constants"
"github.com/aserto-dev/ds-load/cli/pkg/plugin"
"github.com/aserto-dev/ds-load/sdk/common"
"github.com/aserto-dev/ds-load/sdk/common/cc"
"github.com/aserto-dev/ds-load/sdk/common/kongyaml"
)
func main() {
pluginEnum := ""
pluginFinder, err := plugin.NewHomeDirFinder(true)
if err != nil {
os.Stderr.WriteString(err.Error())
os.Exit(1)
}
plugins, err := pluginFinder.Find()
if err != nil {
os.Stderr.WriteString(err.Error())
os.Exit(1)
}
for _, p := range plugins {
pluginEnum += (p.Name + "|")
}
pluginEnum = strings.TrimSuffix(pluginEnum, "|")
yamlLoader := kongyaml.NewYAMLResolver("")
cli := app.CLI{}
options := []kong.Option{
kong.Name(constants.AppName),
kong.Vars{"plugins": pluginEnum},
kong.Description(constants.AppDescription),
kong.UsageOnError(),
kong.Configuration(yamlLoader.Loader, constants.DefaultConfigPath),
kong.ConfigureHelp(kong.HelpOptions{
NoAppSummary: false,
Summary: false,
Compact: true,
Tree: false,
FlagsLast: true,
Indenter: kong.SpaceIndenter,
NoExpandSubcommands: false,
}),
}
kongCtx := kong.Parse(&cli, options...)
ctx := cc.NewCommonContext(cli.Verbosity, string(cli.Config))
if err := kongCtx.Run(ctx); err != nil {
kongCtx.FatalIfErrorf(err)
}
os.Exit(common.GetExitCode())
}