Browse files

Merge pull request #135 from sidprak/add-quiet-option

Add --quiet option to silence output on stdout
  • Loading branch information...
2 parents 0bacdf4 + 990b3bd commit 74c961a8524b84fc120c9b45c45ecfb244522177 @mludvig mludvig committed Mar 9, 2013
Showing with 9 additions and 0 deletions.
  1. +9 −0 s3cmd
View
9 s3cmd
@@ -1827,6 +1827,7 @@ def main():
optparser.add_option( "--version", dest="show_version", action="store_true", help="Show s3cmd version (%s) and exit." % (PkgInfo.version))
optparser.add_option("-F", "--follow-symlinks", dest="follow_symlinks", action="store_true", default=False, help="Follow symbolic links as if they are regular files")
optparser.add_option( "--cache-file", dest="cache_file", action="store", default="", metavar="FILE", help="Cache FILE containing local source MD5 values")
+ optparser.add_option("-q", "--quiet", dest="quiet", action="store_true", default=False, help="Silence output on stdout")
optparser.set_usage(optparser.usage + " COMMAND [parameters]")
optparser.set_description('S3cmd is a tool for managing objects in '+
@@ -1849,6 +1850,14 @@ def main():
output(u"s3cmd version %s" % PkgInfo.version)
sys.exit(0)
+ if options.quiet:
+ try:
+ f = open("/dev/null", "w")
+ sys.stdout.close()
+ sys.stdout = f
+ except IOError:
+ warning(u"--quiet disabled.")
+
## Now finally parse the config file
if not options.config:
error(u"Can't find a config file. Please use --config option.")

0 comments on commit 74c961a

Please sign in to comment.