Skip to content

Commit

Permalink
feat(ls): -q or --quiet to suppress error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
mroach committed Mar 17, 2022
1 parent bda51da commit 1d0239d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cmd/ls.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
func init() {
var outputFormat string
var columns []string
var quiet bool
calcMd5 := false
calcSha := false
calcCrc := false
Expand Down Expand Up @@ -104,7 +105,7 @@ func init() {
return fileInfos[i].File.Name < fileInfos[j].File.Name
})

if len(errs) > 0 {
if len(errs) > 0 && !quiet {
l := log.New(os.Stderr, "", 1)
l.Println("Errors were encountered while listing some files:")
for item := range errs {
Expand All @@ -119,6 +120,7 @@ func init() {
lsCmd.Flags().StringVarP(&outputFormat, "output", "o", "table",
fmt.Sprintf("Output format (%s)", strings.Join(formatters.OutputFormats, ", ")))
lsCmd.Flags().StringSliceVarP(&columns, "columns", "c", make([]string, 0), "Column selection")
lsCmd.Flags().BoolVarP(&quiet, "quiet", "q", false, "Quiet mode. Suppress non-fatal errors.")

rootCmd.AddCommand(lsCmd)
}
Expand Down

0 comments on commit 1d0239d

Please sign in to comment.