mirror of
https://github.com/TECHNOFAB11/jsonnet-bundler.git
synced 2025-12-11 23:50:05 +01:00
Merge pull request #124 from hangxie/add-quiet-option
Add --quiet option to suppress git progress output
This commit is contained in:
commit
ada055a225
3 changed files with 17 additions and 3 deletions
|
|
@ -92,6 +92,7 @@ Flags:
|
||||||
--version Show application version.
|
--version Show application version.
|
||||||
--jsonnetpkg-home="vendor"
|
--jsonnetpkg-home="vendor"
|
||||||
The directory used to cache packages in.
|
The directory used to cache packages in.
|
||||||
|
-q, --quiet Suppress any output from git command.
|
||||||
|
|
||||||
Commands:
|
Commands:
|
||||||
help [<command>...]
|
help [<command>...]
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,8 @@ import (
|
||||||
"github.com/fatih/color"
|
"github.com/fatih/color"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"gopkg.in/alecthomas/kingpin.v2"
|
"gopkg.in/alecthomas/kingpin.v2"
|
||||||
|
|
||||||
|
"github.com/jsonnet-bundler/jsonnet-bundler/pkg"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
@ -49,6 +51,8 @@ func Main() int {
|
||||||
|
|
||||||
a.Flag("jsonnetpkg-home", "The directory used to cache packages in.").
|
a.Flag("jsonnetpkg-home", "The directory used to cache packages in.").
|
||||||
Default("vendor").StringVar(&cfg.JsonnetHome)
|
Default("vendor").StringVar(&cfg.JsonnetHome)
|
||||||
|
a.Flag("quiet", "Suppress any output from git command.").
|
||||||
|
Short('q').BoolVar(&pkg.GitQuiet)
|
||||||
|
|
||||||
initCmd := a.Command(initActionName, "Initialize a new empty jsonnetfile")
|
initCmd := a.Command(initActionName, "Initialize a new empty jsonnetfile")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,13 +48,17 @@ func NewGitPackage(source *deps.Git) Interface {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var GitQuiet = false
|
||||||
|
|
||||||
func downloadGitHubArchive(filepath string, url string) error {
|
func downloadGitHubArchive(filepath string, url string) error {
|
||||||
// Get the data
|
// Get the data
|
||||||
resp, err := http.Get(url)
|
resp, err := http.Get(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if !GitQuiet {
|
||||||
color.Cyan("GET %s %d", url, resp.StatusCode)
|
color.Cyan("GET %s %d", url, resp.StatusCode)
|
||||||
|
}
|
||||||
if resp.StatusCode != 200 {
|
if resp.StatusCode != 200 {
|
||||||
return fmt.Errorf("unexpected status code %d", resp.StatusCode)
|
return fmt.Errorf("unexpected status code %d", resp.StatusCode)
|
||||||
}
|
}
|
||||||
|
|
@ -240,8 +244,13 @@ func (p *GitPackage) Install(ctx context.Context, name, dir, version string) (st
|
||||||
gitCmd := func(args ...string) *exec.Cmd {
|
gitCmd := func(args ...string) *exec.Cmd {
|
||||||
cmd := exec.CommandContext(ctx, "git", args...)
|
cmd := exec.CommandContext(ctx, "git", args...)
|
||||||
cmd.Stdin = os.Stdin
|
cmd.Stdin = os.Stdin
|
||||||
|
if GitQuiet {
|
||||||
|
cmd.Stdout = nil
|
||||||
|
cmd.Stderr = nil
|
||||||
|
} else {
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
|
}
|
||||||
cmd.Dir = tmpDir
|
cmd.Dir = tmpDir
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue