...
1
2
3 package edgeadmin
4
5 import (
6 "context"
7 "fmt"
8 "os"
9
10 cfgmanifest "edge-infra.dev/pkg/edge/edgeadmin/commands/cfg"
11 "edge-infra.dev/pkg/edge/edgeadmin/commands/chart"
12 "edge-infra.dev/pkg/edge/edgeadmin/commands/operatorintervention"
13 "edge-infra.dev/pkg/edge/edgeadmin/commands/version"
14 "edge-infra.dev/pkg/edge/edgecli"
15 "edge-infra.dev/pkg/lib/cli/command"
16 )
17
18 func NewCmd() (command.Command, error) {
19 cfg, err := edgecli.ReadConfig()
20 if err != nil {
21 return command.Command{}, err
22 }
23 root := command.Command{
24 ShortUsage: "edgeadmin",
25 Commands: []*command.Command{
26 cfgmanifest.NewCmd(cfg),
27 operatorintervention.NewCmd(cfg),
28 chart.NewCmd(cfg),
29 version.NewCmd(cfg),
30 },
31 }
32 return root, nil
33 }
34
35 func Run(ctx context.Context) error {
36 c, err := NewCmd()
37 if err != nil {
38 fmt.Println("error: failed to instantiate edgeadmin: ", err)
39 return err
40 }
41 if err := c.Command().ParseAndRun(ctx, os.Args[1:]); err != nil {
42 fmt.Println(err)
43 return err
44 }
45 return nil
46 }
47
View as plain text