-
Notifications
You must be signed in to change notification settings - Fork 6
/
array_ls.go
62 lines (56 loc) · 1.08 KB
/
array_ls.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
package omcmd
import (
"fmt"
"github.com/opensvc/om3/core/client"
"github.com/opensvc/om3/core/clientcontext"
"github.com/opensvc/om3/core/object"
"github.com/opensvc/om3/core/output"
"github.com/opensvc/om3/core/rawconfig"
)
type (
CmdArrayLs struct {
OptsGlobal
}
)
func (t *CmdArrayLs) Run() error {
var (
data []string
err error
)
if t.Local || !clientcontext.IsSet() {
data, err = t.extractLocal()
} else {
data, err = t.extractDaemon()
}
output.Renderer{
Output: t.Output,
Color: t.Color,
Data: data,
HumanRenderer: func() string {
s := ""
for _, e := range data {
s += e + "\n"
}
return s
},
Colorize: rawconfig.Colorize,
}.Print()
return err
}
func (t *CmdArrayLs) extractLocal() ([]string, error) {
n, err := object.NewNode()
if err != nil {
return []string{}, err
}
return n.ListArrays(), nil
}
func (t *CmdArrayLs) extractDaemon() ([]string, error) {
var (
c *client.T
err error
)
if c, err = client.New(client.WithURL(t.Server)); err != nil {
return []string{}, err
}
return []string{}, fmt.Errorf("todo %v", c)
}