From a11bd68b68254cef2b359416a42c2775969e1a1c Mon Sep 17 00:00:00 2001 From: Cameron Sparr Date: Wed, 16 Mar 2016 14:22:01 -0600 Subject: [PATCH] provide args for telegraf for consistency with influxd: - telegraf version - telegraf config closes #857 --- cmd/telegraf/telegraf.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/cmd/telegraf/telegraf.go b/cmd/telegraf/telegraf.go index d54aaa4e3..436d1a38e 100644 --- a/cmd/telegraf/telegraf.go +++ b/cmd/telegraf/telegraf.go @@ -96,8 +96,9 @@ func main() { reload <- false flag.Usage = func() { usageExit(0) } flag.Parse() + args := flag.Args() - if flag.NFlag() == 0 { + if flag.NFlag() == 0 && len(args) == 0 { usageExit(0) } @@ -121,6 +122,18 @@ func main() { outputFilters = strings.Split(":"+outputFilter+":", ":") } + if len(args) > 0 { + switch args[0] { + case "version": + v := fmt.Sprintf("Telegraf - Version %s", Version) + fmt.Println(v) + return + case "config": + config.PrintSampleConfig(inputFilters, outputFilters) + return + } + } + if *fOutputList { fmt.Println("Available Output Plugins:") for k, _ := range outputs.Outputs {