diff options
Diffstat (limited to 'code')
-rwxr-xr-x | code/templates/script.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/code/templates/script.py b/code/templates/script.py index 861ee70..d1ba416 100755 --- a/code/templates/script.py +++ b/code/templates/script.py @@ -1,7 +1,7 @@ #!/usr/bin/env python import sys -import optparse +import argparse import logging log = logging.getLogger(__name__) @@ -15,21 +15,21 @@ def run(): def main(): global log - parser = optparse.OptionParser(usage= - "usage: %prog [options]\n" - "%prog --help for more info." - ) - parser.add_option("-v", "--verbose", + parser = argparse.ArgumentParser() + parser.add_argument("-v", "--verbose", default=False, help="Show more debugging statements", action="store_true") + parser.add_argument("commands", nargs='*') - (options, args) = parser.parse_args() + options = parser.parse_args() + args = options.commands if len(args) != 0: parser.error("Incorrect number of arguments") log = logging.getLogger() + log.addHandler(logging.StreamHandler()) if options.verbose: log.setLevel(logging.DEBUG) else: |