Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the option to influx CLI to execute single command and exit. #2214

Merged
merged 1 commit into from
Apr 9, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion cmd/influx/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type CommandLine struct {
Pretty bool // controls pretty print for json
Format string // controls the output format. Valid values are json, csv, or column
ShouldDump bool
Execute string
}

func main() {
Expand All @@ -55,6 +56,7 @@ func main() {
fs.StringVar(&c.Database, "database", c.Database, "database to connect to the server.")
fs.StringVar(&c.Format, "output", default_format, "format specifies the format of the server responses: json, csv, or column")
fs.BoolVar(&c.ShouldDump, "dump", false, "dump the contents of the given database to stdout")
fs.StringVar(&c.Execute, "execute", c.Execute, "Execute command and quit.")
fs.Parse(os.Args[1:])

var promptForPassword bool
Expand Down Expand Up @@ -86,6 +88,11 @@ func main() {
return
}

if c.Execute != "" {
c.executeQuery(c.Execute)
return
}

fmt.Println("InfluxDB shell " + version)

var historyFile string
Expand Down Expand Up @@ -211,7 +218,7 @@ func (c *CommandLine) connect(cmd string) {
fmt.Printf("Failed to connect to %s\n", c.Client.Addr())
} else {
c.Version = v
if !c.ShouldDump {
if !c.ShouldDump && c.Execute == "" {
fmt.Printf("Connected to %s version %s\n", c.Client.Addr(), c.Version)
}
}
Expand Down