fea: openlan: list users filter by network

This commit is contained in:
Daniel Ding
2022-10-18 21:10:31 +08:00
parent 79e830fd56
commit b4c02b049a
5 changed files with 66 additions and 4 deletions

View File

@@ -34,6 +34,16 @@ func (u Link) List(c *cli.Context) error {
if err := clt.GetJSON(url, &items); err != nil {
return err
}
name := c.String("network")
if len(name) > 0 {
tmp := items[:0]
for _, obj := range items {
if obj.Network == name {
tmp = append(tmp, obj)
}
}
items = tmp
}
return u.Out(items, c.String("format"), u.Tmpl())
}
@@ -47,7 +57,10 @@ func (u Link) Commands(app *api.App) {
Name: "list",
Usage: "Display all links",
Aliases: []string{"ls"},
Action: u.List,
Flags: []cli.Flag{
&cli.StringFlag{Name: "network"},
},
Action: u.List,
},
},
})