fix(agent): catch non-existing commands and error out (#12549)

This commit is contained in:
Sven Rebhan 2023-01-25 15:54:51 +01:00 committed by GitHub
parent d9d6a997e1
commit f5122893e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -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