mirror of
https://github.com/anchore/syft.git
synced 2025-11-17 16:33:21 +01:00
show message when no packages are discovered (#115)
This commit is contained in:
parent
c67e17a2cf
commit
5320280216
@ -1,6 +1,7 @@
|
|||||||
package table
|
package table
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
@ -35,6 +36,11 @@ func (pres *Presenter) Present(output io.Writer) error {
|
|||||||
rows = append(rows, row)
|
rows = append(rows, row)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(rows) == 0 {
|
||||||
|
fmt.Fprintln(output, "No packages discovered")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// sort by name, version, then type
|
// sort by name, version, then type
|
||||||
sort.SliceStable(rows, func(i, j int) bool {
|
sort.SliceStable(rows, func(i, j int) bool {
|
||||||
for col := 0; col < len(columns); col++ {
|
for col := 0; col < len(columns); col++ {
|
||||||
@ -57,7 +63,7 @@ func (pres *Presenter) Present(output io.Writer) error {
|
|||||||
table.SetCenterSeparator("")
|
table.SetCenterSeparator("")
|
||||||
table.SetColumnSeparator("")
|
table.SetColumnSeparator("")
|
||||||
table.SetRowSeparator("")
|
table.SetRowSeparator("")
|
||||||
table.SetTablePadding("\t")
|
table.SetTablePadding(" ")
|
||||||
table.SetNoWhiteSpace(true)
|
table.SetNoWhiteSpace(true)
|
||||||
|
|
||||||
table.AppendBulk(rows)
|
table.AppendBulk(rows)
|
||||||
|
|||||||
@ -48,6 +48,7 @@ func (pres *Presenter) Present(output io.Writer) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// populate artifacts...
|
// populate artifacts...
|
||||||
|
rows := 0
|
||||||
for _, p := range pres.catalog.Sorted() {
|
for _, p := range pres.catalog.Sorted() {
|
||||||
fmt.Fprintln(w, fmt.Sprintf("[%s]", p.Name))
|
fmt.Fprintln(w, fmt.Sprintf("[%s]", p.Name))
|
||||||
fmt.Fprintln(w, " Version:\t", p.Version)
|
fmt.Fprintln(w, " Version:\t", p.Version)
|
||||||
@ -55,6 +56,12 @@ func (pres *Presenter) Present(output io.Writer) error {
|
|||||||
fmt.Fprintln(w, " Found by:\t", p.FoundBy)
|
fmt.Fprintln(w, " Found by:\t", p.FoundBy)
|
||||||
fmt.Fprintln(w)
|
fmt.Fprintln(w)
|
||||||
w.Flush()
|
w.Flush()
|
||||||
|
rows++
|
||||||
|
}
|
||||||
|
|
||||||
|
if rows == 0 {
|
||||||
|
fmt.Fprintln(output, "No packages discovered")
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user