Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion cmd/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,12 @@ func cliCommands() []*cli.Command {
Description: toxicDescription,
Subcommands: cliToxiSubCommands(),
},
{
Name: "reset",
Usage: "enable all proxies and remove all active toxics\n\tusage: 'toxiproxy-cli reset'\n",
Aliases: []string{"rst"},
Action: withToxi(reset),
},
}
}

Expand Down Expand Up @@ -273,7 +279,7 @@ func withToxi(f toxiAction) func(*cli.Context) error {
}
}

func list(c *cli.Context, t *toxiproxy.Client) error {
func list(_ *cli.Context, t *toxiproxy.Client) error {
proxies, err := t.Proxies()
if err != nil {
return errorf("Failed to retrieve proxies: %s", err)
Expand Down Expand Up @@ -514,6 +520,17 @@ func removeToxic(c *cli.Context, t *toxiproxy.Client) error {
return nil
}

func reset(_ *cli.Context, t *toxiproxy.Client) error {
err := t.ResetState()
if err != nil {
return errorf("Failed to reset state: %s", err)
}

fmt.Printf("Enabled all proxies and removed all active toxics\n")

return nil
}

func parseToxicCommonParams(context *cli.Context) (*toxiproxy.ToxicOptions, error) {
proxyName := context.Args().First()
if proxyName == "" {
Expand Down