From 5656ba167f55ce731dc5848e6fb61abdbd4c1cea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Bouchex=20Bellomi=C3=A9?= Date: Fri, 11 Sep 2015 10:04:18 +0200 Subject: [PATCH] Added precision support in cmd client --- client/influxdb.go | 5 +++++ cmd/influx/main.go | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/client/influxdb.go b/client/influxdb.go index 35dc54730c6..3d5146f17d3 100644 --- a/client/influxdb.go +++ b/client/influxdb.go @@ -128,6 +128,11 @@ func (c *Client) SetAuth(u, p string) { c.password = p } +// SetPrecision will update the precision +func (c *Client) SetPrecision(precision string) { + c.precision = precision +} + // Query sends a command to the server and returns the Response func (c *Client) Query(q Query) (*Response, error) { u := c.url diff --git a/cmd/influx/main.go b/cmd/influx/main.go index 551691bf437..81ad6c8133f 100644 --- a/cmd/influx/main.go +++ b/cmd/influx/main.go @@ -165,6 +165,8 @@ Examples: } if c.Execute != "" { + // Modify precision before executing query + c.SetPrecision(c.Precision) if err := c.ExecuteQuery(c.Execute); err != nil { c.Line.Close() os.Exit(1) @@ -371,8 +373,10 @@ func (c *CommandLine) SetPrecision(cmd string) { switch cmd { case "h","m","s","ms","u","ns": c.Precision = cmd + c.Client.SetPrecision(c.Precision) case "rfc3339": - c.Precision = ""; + c.Precision = "" + c.Client.SetPrecision(c.Precision) default: fmt.Printf("Unknown precision %q. Please use rfc3339, h, m, s, ms, u or ns.\n", cmd) }