Add --quiet option to silence output on stdout
Michal Ludvig authored on 2013/03/09 09:19:57... | ... |
@@ -1827,6 +1827,7 @@ def main(): |
1827 | 1827 |
optparser.add_option( "--version", dest="show_version", action="store_true", help="Show s3cmd version (%s) and exit." % (PkgInfo.version)) |
1828 | 1828 |
optparser.add_option("-F", "--follow-symlinks", dest="follow_symlinks", action="store_true", default=False, help="Follow symbolic links as if they are regular files") |
1829 | 1829 |
optparser.add_option( "--cache-file", dest="cache_file", action="store", default="", metavar="FILE", help="Cache FILE containing local source MD5 values") |
1830 |
+ optparser.add_option("-q", "--quiet", dest="quiet", action="store_true", default=False, help="Silence output on stdout") |
|
1830 | 1831 |
|
1831 | 1832 |
optparser.set_usage(optparser.usage + " COMMAND [parameters]") |
1832 | 1833 |
optparser.set_description('S3cmd is a tool for managing objects in '+ |
... | ... |
@@ -1849,6 +1850,14 @@ def main(): |
1849 | 1849 |
output(u"s3cmd version %s" % PkgInfo.version) |
1850 | 1850 |
sys.exit(0) |
1851 | 1851 |
|
1852 |
+ if options.quiet: |
|
1853 |
+ try: |
|
1854 |
+ f = open("/dev/null", "w") |
|
1855 |
+ sys.stdout.close() |
|
1856 |
+ sys.stdout = f |
|
1857 |
+ except IOError: |
|
1858 |
+ warning(u"--quiet disabled.") |
|
1859 |
+ |
|
1852 | 1860 |
## Now finally parse the config file |
1853 | 1861 |
if not options.config: |
1854 | 1862 |
error(u"Can't find a config file. Please use --config option.") |