mirror of
https://codeberg.org/scip/esctl.git
synced 2026-08-24 15:14:18 +02:00
add node show + node clients (#61)
This commit is contained in:
45
cmd/node.go
45
cmd/node.go
@@ -18,6 +18,7 @@ package cmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"codeberg.org/scip/esctl/pkg/cfg"
|
||||
"codeberg.org/scip/esctl/pkg/es"
|
||||
@@ -34,6 +35,7 @@ func Node(conf *cfg.Config) *cli.Command {
|
||||
Commands: []*cli.Command{
|
||||
NodeList(conf),
|
||||
NodeShow(conf),
|
||||
NodeClients(conf),
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -57,10 +59,47 @@ func NodeShow(conf *cfg.Config) *cli.Command {
|
||||
Usage: "show details about a node",
|
||||
UsageText: "show [options] <node>",
|
||||
|
||||
ShellComplete: func(ctx context.Context, cmd *cli.Command) {
|
||||
complete(cmd, Cnode)
|
||||
},
|
||||
|
||||
Action: func(ctx context.Context, cmd *cli.Command) error {
|
||||
// FIXME: implement es.NodeShow()
|
||||
// return es.NodeShow(conf, cmd.Args().Get(0))
|
||||
return nil
|
||||
node := cmd.Args().Get(0)
|
||||
if node == "" {
|
||||
return errors.New("no node specified")
|
||||
}
|
||||
|
||||
return es.NodeShow(conf, node)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func NodeClients(conf *cfg.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "clients",
|
||||
Usage: "show node http clients",
|
||||
UsageText: "clients [options] <node>",
|
||||
|
||||
Flags: []cli.Flag{
|
||||
&cli.BoolFlag{
|
||||
Name: "query",
|
||||
Usage: "include query parameters",
|
||||
Destination: &conf.All,
|
||||
Aliases: []string{"q"},
|
||||
},
|
||||
},
|
||||
|
||||
ShellComplete: func(ctx context.Context, cmd *cli.Command) {
|
||||
complete(cmd, Cnode)
|
||||
},
|
||||
|
||||
Action: func(ctx context.Context, cmd *cli.Command) error {
|
||||
node := cmd.Args().Get(0)
|
||||
if node == "" {
|
||||
return errors.New("no node specified")
|
||||
}
|
||||
|
||||
return es.NodeClients(conf, node)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user