/
app.go
42 lines (34 loc) · 1.11 KB
/
app.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
package bifrost
import (
"github.com/ClessLi/bifrost/internal/bifrost/config"
"github.com/ClessLi/bifrost/internal/bifrost/options"
"github.com/ClessLi/component-base/pkg/app"
)
const commandDesc = `The Bifrost is used to parse the nginx configuration file
and provide an interface for displaying and modifying the configuration file.
It supports the mutual conversion of JSON, string format and golang structure.
The Bifrost services to do the api objects management with gRPC protocol.
Find more Bifrost information at:
https://github.com/ClessLi/bifrost/blob/master/docs/guide/en-US/cmd/bifrost.md`
func NewApp(basename string) *app.App {
opts := options.NewOptions()
application := app.NewApp("Bifrost",
basename,
app.WithOptions(opts),
app.WithDescription(commandDesc),
app.WithDefaultValidArgs(),
app.WithRunFunc(run(opts)),
)
return application
}
func run(opts *options.Options) app.RunFunc {
return func(basename string) error {
// init auth api client
// auth.Init(opts.AuthAPIClient)
cfg, err := config.CreateConfigFromOptions(opts)
if err != nil {
return err
}
return Run(cfg)
}
}