func doDownload(flags *flag.FlagSet) error { buildStr := flags.Arg(0) val, err := strconv.Atoi(buildStr) if err != nil { return err } remote, err := git.GetRemoteURL("origin") if err != nil { return err } arts, err := circle.GetArtifactsForBuild(remote.Path, remote.RepoName, val) if err != nil { return err } var wg sync.WaitGroup tempDir, err := ioutil.TempDir("", "circle-artifacts") if err != nil { return err } for _, art := range arts { wg.Add(1) go func(a *circle.CircleArtifact) { if err := circle.DownloadArtifact(a, tempDir, remote.Path); err != nil { fmt.Fprintln(os.Stderr, err) } wg.Done() }(art) } wg.Wait() fmt.Fprintf(os.Stderr, "Wrote all artifacts for build %d to %s\n", val, tempDir) return nil }
func doOpen(flags *flag.FlagSet) { args := flags.Args() branch, err := getBranchFromArgs(args) checkError(err) remote, err := git.GetRemoteURL("origin") checkError(err) cr, err := circle.GetTree(remote.Path, remote.RepoName, branch) checkError(err) if len(*cr) == 0 { fmt.Printf("No results, are you sure there are tests for %s/%s?\n", remote.Path, remote.RepoName) return } latestBuild := (*cr)[0] open.Start(latestBuild.BuildURL) }