From f5122893e3d5b63cafd52c98026c432f4c2dc546 Mon Sep 17 00:00:00 2001 From: Sven Rebhan <36194019+srebhan@users.noreply.github.com> Date: Wed, 25 Jan 2023 15:54:51 +0100 Subject: [PATCH] fix(agent): catch non-existing commands and error out (#12549) --- cmd/telegraf/main.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmd/telegraf/main.go b/cmd/telegraf/main.go index 95498a2c4..9826d9947 100644 --- a/cmd/telegraf/main.go +++ b/cmd/telegraf/main.go @@ -129,8 +129,13 @@ func runApp(args []string, outputBuffer io.Writer, pprof Server, c TelegrafConfi extraFlags := append(pluginFilterFlags, cliFlags()...) // This function is used when Telegraf is run with only flags - action := func(cCtx *cli.Context) error { + // We do not expect any arguments this is likely a misspelling of + // a command... + if cCtx.NArg() > 0 { + return fmt.Errorf("unknown command %q", cCtx.Args().First()) + } + err := logger.SetupLogging(logger.LogConfig{}) if err != nil { return err