diff options
author | 2023-09-12 23:52:36 +0000 | |
---|---|---|
committer | 2023-09-13 00:10:47 +0000 | |
commit | 3730d7e653f0b520d221d1ccd7ec22aa380addd2 (patch) | |
tree | 767e3890abfbdb664d28699e5a30ca2e56f8b297 /zip | |
parent | ff8fb5c6cc3796a6d5965384b76b5c779ba309e0 (diff) |
Add `-quiet` option in soong_zip
The quiet option prevents warnings from being printed to the console.
Test: m soong_zip
Bug: 300166930
Change-Id: I4c2c5f16c45c2874a2a2cbb1e3f397124043e472
Diffstat (limited to 'zip')
-rw-r--r-- | zip/cmd/main.go | 2 | ||||
-rw-r--r-- | zip/zip.go | 13 |
2 files changed, 12 insertions, 3 deletions
diff --git a/zip/cmd/main.go b/zip/cmd/main.go index 5231faec9..37537ab8b 100644 --- a/zip/cmd/main.go +++ b/zip/cmd/main.go @@ -174,6 +174,7 @@ func main() { traceFile := flags.String("trace", "", "write trace to file") sha256Checksum := flags.Bool("sha256", false, "add a zip header to each file containing its SHA256 digest") doNotWrite := flags.Bool("n", false, "Nothing is written to disk -- all other work happens") + quiet := flags.Bool("quiet", false, "do not print warnings to console") flags.Var(&rootPrefix{}, "P", "path prefix within the zip at which to place files") flags.Var(&listFiles{}, "l", "file containing list of files to zip") @@ -238,6 +239,7 @@ func main() { IgnoreMissingFiles: *ignoreMissingFiles, Sha256Checksum: *sha256Checksum, DoNotWrite: *doNotWrite, + Quiet: *quiet, }) if err != nil { fmt.Fprintln(os.Stderr, "error:", err.Error()) diff --git a/zip/zip.go b/zip/zip.go index 30a2ee762..f91a5f2cb 100644 --- a/zip/zip.go +++ b/zip/zip.go @@ -283,6 +283,7 @@ type ZipArgs struct { IgnoreMissingFiles bool Sha256Checksum bool DoNotWrite bool + Quiet bool Stderr io.Writer Filesystem pathtools.FileSystem @@ -340,7 +341,9 @@ func zipTo(args ZipArgs, w io.Writer) error { Err: os.ErrNotExist, } if args.IgnoreMissingFiles { - fmt.Fprintln(z.stderr, "warning:", err) + if !args.Quiet { + fmt.Fprintln(z.stderr, "warning:", err) + } } else { return err } @@ -357,7 +360,9 @@ func zipTo(args ZipArgs, w io.Writer) error { Err: os.ErrNotExist, } if args.IgnoreMissingFiles { - fmt.Fprintln(z.stderr, "warning:", err) + if !args.Quiet { + fmt.Fprintln(z.stderr, "warning:", err) + } } else { return err } @@ -368,7 +373,9 @@ func zipTo(args ZipArgs, w io.Writer) error { Err: syscall.ENOTDIR, } if args.IgnoreMissingFiles { - fmt.Fprintln(z.stderr, "warning:", err) + if !args.Quiet { + fmt.Fprintln(z.stderr, "warning:", err) + } } else { return err } |