mirror of
https://codeberg.org/scip/esctl.git
synced 2026-08-24 04:54:18 +02:00
shards, aliases and filtering (#18)
This commit is contained in:
55
cmd/index.go
55
cmd/index.go
@@ -18,6 +18,7 @@ package cmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"codeberg.org/scip/esctl/pkg/cfg"
|
||||
@@ -39,6 +40,8 @@ func Index(conf *cfg.Config) *cli.Command {
|
||||
IndexDelete(conf),
|
||||
IndexClose(conf),
|
||||
IndexAllocation(conf),
|
||||
IndexModify(conf),
|
||||
IndexAlias(conf),
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -68,6 +71,12 @@ func IndexList(conf *cfg.Config) *cli.Command {
|
||||
Destination: &conf.Failed,
|
||||
Aliases: []string{"r"},
|
||||
},
|
||||
&cli.StringSliceFlag{
|
||||
Name: "filter",
|
||||
Usage: "show only indicies matching the filter",
|
||||
Destination: &conf.Filter,
|
||||
Aliases: []string{"F"},
|
||||
},
|
||||
},
|
||||
|
||||
Action: func(ctx context.Context, cmd *cli.Command) error {
|
||||
@@ -98,6 +107,11 @@ func IndexAllocation(conf *cfg.Config) *cli.Command {
|
||||
},
|
||||
|
||||
Action: func(ctx context.Context, cmd *cli.Command) error {
|
||||
index := cmd.Args().Get(0)
|
||||
if index == "" {
|
||||
return errors.New("no index specified")
|
||||
}
|
||||
|
||||
return es.IndexAllocation(conf, cmd.Args().Get(0))
|
||||
},
|
||||
}
|
||||
@@ -110,6 +124,11 @@ func IndexShow(conf *cfg.Config) *cli.Command {
|
||||
Usage: "show details about an index",
|
||||
|
||||
Action: func(ctx context.Context, cmd *cli.Command) error {
|
||||
index := cmd.Args().Get(0)
|
||||
if index == "" {
|
||||
return errors.New("no index specified")
|
||||
}
|
||||
|
||||
return es.IndexShow(conf, cmd.Args().Get(0))
|
||||
},
|
||||
|
||||
@@ -180,6 +199,11 @@ func IndexDelete(conf *cfg.Config) *cli.Command {
|
||||
Usage: "delete an index",
|
||||
|
||||
Action: func(ctx context.Context, cmd *cli.Command) error {
|
||||
index := cmd.Args().Get(0)
|
||||
if index == "" {
|
||||
return errors.New("no index specified")
|
||||
}
|
||||
|
||||
return es.IndexDelete(conf, cmd.Args().Get(0))
|
||||
},
|
||||
}
|
||||
@@ -191,7 +215,38 @@ func IndexClose(conf *cfg.Config) *cli.Command {
|
||||
Usage: "close an index",
|
||||
|
||||
Action: func(ctx context.Context, cmd *cli.Command) error {
|
||||
index := cmd.Args().Get(0)
|
||||
if index == "" {
|
||||
return errors.New("no index specified")
|
||||
}
|
||||
|
||||
return es.IndexClose(conf, cmd.Args().Get(0))
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func IndexModify(conf *cfg.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "modify",
|
||||
Usage: "modify an index",
|
||||
UsageText: "modify <index[,index,...]|_all>",
|
||||
|
||||
Flags: []cli.Flag{
|
||||
&cli.IntFlag{
|
||||
Name: "replicas",
|
||||
Usage: "number of replicas",
|
||||
Destination: &conf.Replicas,
|
||||
Aliases: []string{"r"},
|
||||
},
|
||||
},
|
||||
|
||||
Action: func(ctx context.Context, cmd *cli.Command) error {
|
||||
index := cmd.Args().Get(0)
|
||||
if index == "" {
|
||||
return errors.New("no index specified")
|
||||
}
|
||||
|
||||
return es.IndexModify(conf, index)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user