Browse code

Add quiet option to silence output on stdout

Siddarth Prakash authored on 2013/03/08 07:46:19
Showing 1 changed files
... ...
@@ -1808,6 +1808,7 @@ def main():
1808 1808
     optparser.add_option(      "--version", dest="show_version", action="store_true", help="Show s3cmd version (%s) and exit." % (PkgInfo.version))
1809 1809
     optparser.add_option("-F", "--follow-symlinks", dest="follow_symlinks", action="store_true", default=False, help="Follow symbolic links as if they are regular files")
1810 1810
     optparser.add_option(      "--cache-file", dest="cache_file", action="store", default="",  metavar="FILE", help="Cache FILE containing local source MD5 values")
1811
+    optparser.add_option("-q", "--quiet", dest="quiet", action="store_true", default=False, help="Silence output on stdout")
1811 1812
 
1812 1813
     optparser.set_usage(optparser.usage + " COMMAND [parameters]")
1813 1814
     optparser.set_description('S3cmd is a tool for managing objects in '+
... ...
@@ -1830,6 +1831,10 @@ def main():
1830 1830
         output(u"s3cmd version %s" % PkgInfo.version)
1831 1831
         sys.exit(0)
1832 1832
 
1833
+    if options.quiet:
1834
+        sys.stdout.close()
1835
+        sys.stdout = open("/dev/null", "w")
1836
+
1833 1837
     ## Now finally parse the config file
1834 1838
     if not options.config:
1835 1839
         error(u"Can't find a config file. Please use --config option.")