func NewEvictLeaderSchedulerCommand() *cobra.Command {
	c := &cobra.Command{
		Use:   "evict-leader-scheduler <store_id>",
		Short: "add a scheduler to evict leader from a store",
		Run:   addSchedulerForStoreCommandFunc,
	}
	return c
}
NewEvictLeaderSchedulerCommand returns a command to add a evict-leader-scheduler.
package command
import (
	"bytes"
	"encoding/json"
	"fmt"
	"net/http"
	"net/url"
	"path"
	"strconv"
	"strings"
	"github.com/pingcap/errors"
	"github.com/spf13/cobra"
	"github.com/tikv/pd/server/schedulers"
)
var (
	schedulersPrefix         = "pd/api/v1/schedulers"
	schedulerConfigPrefix    = "pd/api/v1/scheduler-config"
	evictLeaderSchedulerName = "evict-leader-scheduler"
	grantLeaderSchedulerName = "grant-leader-scheduler"
)
func NewSchedulerCommand() *cobra.Command {
	c := &cobra.Command{
		Use:   "scheduler",
		Short: "scheduler commands",
	}
	c.AddCommand(NewShowSchedulerCommand())
	c.AddCommand(NewAddSchedulerCommand())
	c.AddCommand(NewRemoveSchedulerCommand())
	c.AddCommand(NewPauseSchedulerCommand())
	c.AddCommand(NewResumeSchedulerCommand())
	c.AddCommand(NewConfigSchedulerCommand())
	return c
}
func NewPauseSchedulerCommand() *cobra.Command {
	c := &cobra.Command{
		Use:   "pause <scheduler> <delay>",
		Short: "pause a scheduler",
		Run:   pauseOrResumeSchedulerCommandFunc,
	}
	return c
}
func pauseOrResumeSchedulerCommandFunc(cmd *cobra.Command, args []string) {
	if len(args) != 2 && len(args) != 1 {
		cmd.Usage()
		return
	}
	path := schedulersPrefix + "/" + args[0]
	input := make(map[string]interface{})
	input["delay"] = 0
	if len(args) == 2 {
		delay, err := strconv.Atoi(args[1])
		if err != nil {
			cmd.Usage()
			return
		}
		input["delay"] = delay
	}
	postJSON(cmd, path, input)
}
func NewShowSchedulerCommand() *cobra.Command {
	c := &cobra.Command{
		Use:   "show",
		Short: "show schedulers",
		Run:   showSchedulerCommandFunc,
	}
	c.Flags().String("status", "", "the scheduler status")
	return c
}
func NewResumeSchedulerCommand() *cobra.Command {
	c := &cobra.Command{
		Use:   "resume <scheduler>",
		Short: "resume a scheduler",
		Run:   pauseOrResumeSchedulerCommandFunc,
	}
	return c
}
func showSchedulerCommandFunc(cmd *cobra.Command, args []string) {
	if len(args) != 0 {
		cmd.Println(cmd.UsageString())
		return
	}
	url := schedulersPrefix
	if flag := cmd.Flag("status"); flag != nil && flag.Value.String() != "" {
		url = fmt.Sprintf("%s?status=%s", url, flag.Value.String())
	}
	r, err := doRequest(cmd, url, http.MethodGet)
	if err != nil {
		cmd.Println(err)
		return
	}
	cmd.Println(r)
}
func NewAddSchedulerCommand() *cobra.Command {
	c := &cobra.Command{
		Use:   "add <scheduler>",
		Short: "add a scheduler",
	}
	c.AddCommand(NewGrantLeaderSchedulerCommand())
	c.AddCommand(NewEvictLeaderSchedulerCommand())
	c.AddCommand(NewShuffleLeaderSchedulerCommand())
	c.AddCommand(NewShuffleRegionSchedulerCommand())
	c.AddCommand(NewShuffleHotRegionSchedulerCommand())
	c.AddCommand(NewScatterRangeSchedulerCommand())
	c.AddCommand(NewBalanceLeaderSchedulerCommand())
	c.AddCommand(NewBalanceRegionSchedulerCommand())
	c.AddCommand(NewBalanceHotRegionSchedulerCommand())
	c.AddCommand(NewRandomMergeSchedulerCommand())
	c.AddCommand(NewLabelSchedulerCommand())
	c.AddCommand(NewEvictSlowStoreSchedulerCommand())
	return c
}
func NewGrantLeaderSchedulerCommand() *cobra.Command {
	c := &cobra.Command{
		Use:   "grant-leader-scheduler <store_id>",
		Short: "add a scheduler to grant leader to a store",
		Run:   addSchedulerForStoreCommandFunc,
	}
	return c
}