Skip to content

Commit

Permalink
Added precision support in cmd client
Browse files Browse the repository at this point in the history
  • Loading branch information
sbouchex committed Sep 11, 2015
1 parent 9831ab2 commit 5656ba1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions client/influxdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion cmd/influx/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 5656ba1

Please sign in to comment.