write progress while downloading assets

[#76848252]

Signed-off-by: Alex Suraci <asuraci@pivotal.io>
This commit is contained in:
Chris Brown
2015-02-18 09:54:44 -08:00
committed by Alex Suraci
parent 8b3dc6edbe
commit 2878392b08
3 changed files with 6 additions and 3 deletions

View File

@@ -19,7 +19,7 @@ func main() {
destDir := os.Args[1]
github := resource.NewGitHubClient(request.Source)
command := resource.NewInCommand(github)
command := resource.NewInCommand(github, os.Stderr)
response, err := command.Run(destDir, request)
if err != nil {
resource.Fatal("running command", err)

View File

@@ -14,11 +14,13 @@ import (
type InCommand struct {
github GitHub
writer io.Writer
}
func NewInCommand(github GitHub) *InCommand {
func NewInCommand(github GitHub, writer io.Writer) *InCommand {
return &InCommand{
github: github,
writer: writer,
}
}
@@ -81,6 +83,7 @@ func (c *InCommand) Run(destDir string, request InRequest) (InResponse, error) {
continue
}
fmt.Fprintf(c.writer, "downloading asset: %s\n", *asset.Name)
err := c.downloadFile(url, path)
if err != nil {
return InResponse{}, nil

View File

@@ -32,7 +32,7 @@ var _ = Describe("In Command", func() {
var err error
githubClient = &fakes.FakeGitHub{}
command = resource.NewInCommand(githubClient)
command = resource.NewInCommand(githubClient, ioutil.Discard)
destDir, err = ioutil.TempDir("", "github-release")
Ω(err).ShouldNot(HaveOccurred())