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

Add a quiet flag to close #9 #14

Merged
merged 1 commit into from
Dec 17, 2016
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
25 changes: 19 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"flag"
"fmt"
"io/ioutil"
"log"
"os"
"regexp"
Expand Down Expand Up @@ -30,6 +31,7 @@ func main() {
history = flag.Duration("history", time.Hour*24, "Historical data to use for finished builds")
debug = flag.Bool("debug", false, "Show API debugging output")
version = flag.Bool("version", false, "Show the version")
quiet = flag.Bool("quiet", false, "Only print errors")

// filters
queue = flag.String("queue", "", "Only include a specific queue")
Expand All @@ -43,16 +45,23 @@ func main() {
}

if *accessToken == "" {
log.Fatal("Must provide a value for -token")
fmt.Println("Must provide a value for -token")
os.Exit(1)
}

if *orgSlug == "" {
log.Fatal("Must provide a value for -org")
fmt.Println("Must provide a value for -org")
os.Exit(1)
}

if *quiet {
log.SetOutput(ioutil.Discard)
}

config, err := buildkite.NewTokenConfig(*accessToken, false)
if err != nil {
log.Fatalf("client config failed: %s", err)
fmt.Printf("client config failed: %s\n", err)
os.Exit(1)
}

client := buildkite.NewClient(config.Client())
Expand All @@ -70,7 +79,9 @@ func main() {
return err
}

dumpResults(res)
if !*quiet {
dumpResults(res)
}

err = cloudwatchSend(res)
if err != nil {
Expand All @@ -82,13 +93,15 @@ func main() {
}

if err := f(); err != nil {
log.Fatal(err)
fmt.Println(err)
os.Exit(1)
}

if *interval > 0 {
for _ = range time.NewTicker(*interval).C {
if err := f(); err != nil {
log.Println(err)
fmt.Println(err)
os.Exit(1)
}
}
}
Expand Down