mirror of
https://github.com/anchore/syft.git
synced 2026-02-12 02:26:42 +01:00
fix quiet flag (#2081)
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
This commit is contained in:
parent
51d38f8e59
commit
36d794febe
@ -29,7 +29,7 @@ func New(id clio.Identification) clio.Application {
|
||||
// select a UI based on the logging configuration and state of stdin (if stdin is a tty)
|
||||
func(cfg clio.Config) ([]clio.UI, error) {
|
||||
noUI := ui.None(cfg.Log.Quiet)
|
||||
if !cfg.Log.AllowUI(os.Stdin) {
|
||||
if !cfg.Log.AllowUI(os.Stdin) || cfg.Log.Quiet {
|
||||
return []clio.UI{noUI}, nil
|
||||
}
|
||||
|
||||
|
||||
@ -36,6 +36,24 @@ func TestPackagesCmdFlags(t *testing.T) {
|
||||
assertSuccessfulReturnCode,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "quiet-flag-with-logger",
|
||||
args: []string{"packages", "-qvv", "-o", "json", coverageImage},
|
||||
assertions: []traitAssertion{
|
||||
assertJsonReport,
|
||||
assertNoStderr,
|
||||
assertSuccessfulReturnCode,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "quiet-flag-with-tui",
|
||||
args: []string{"packages", "-q", "-o", "json", coverageImage},
|
||||
assertions: []traitAssertion{
|
||||
assertJsonReport,
|
||||
assertNoStderr,
|
||||
assertSuccessfulReturnCode,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "multiple-output-flags",
|
||||
args: []string{"packages", "-o", "table", "-o", "json=" + tmp + ".tmp/multiple-output-flag-test.json", coverageImage},
|
||||
|
||||
@ -83,6 +83,13 @@ func assertNotInOutput(data string) traitAssertion {
|
||||
}
|
||||
}
|
||||
|
||||
func assertNoStderr(tb testing.TB, _, stderr string, _ int) {
|
||||
tb.Helper()
|
||||
if len(stderr) > 0 {
|
||||
tb.Errorf("expected stderr to be empty, but got %q", stderr)
|
||||
}
|
||||
}
|
||||
|
||||
func assertInOutput(data string) traitAssertion {
|
||||
return func(tb testing.TB, stdout, stderr string, _ int) {
|
||||
tb.Helper()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user