Skip to content

Commit

Permalink
Merge pull request #135 from sidprak/add-quiet-option
Browse files Browse the repository at this point in the history
Add --quiet option to silence output on stdout
  • Loading branch information
mludvig committed Mar 9, 2013
2 parents 0bacdf4 + 990b3bd commit 74c961a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions s3cmd
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -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( "--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("-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( "--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_usage(optparser.usage + " COMMAND [parameters]")
optparser.set_description('S3cmd is a tool for managing objects in '+ optparser.set_description('S3cmd is a tool for managing objects in '+
Expand All @@ -1849,6 +1850,14 @@ def main():
output(u"s3cmd version %s" % PkgInfo.version) output(u"s3cmd version %s" % PkgInfo.version)
sys.exit(0) 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 ## Now finally parse the config file
if not options.config: if not options.config:
error(u"Can't find a config file. Please use --config option.") error(u"Can't find a config file. Please use --config option.")
Expand Down

0 comments on commit 74c961a

Please sign in to comment.