summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbryan newbold <bnewbold@leaflabs.com>2013-09-25 12:28:59 -0400
committerbryan newbold <bnewbold@leaflabs.com>2013-09-25 12:31:06 -0400
commit1779ef7c07a26e7a9e51999066fe55ba85b945b2 (patch)
treef628ea6a0e6472d4fdf36897c450ef2040a71f6c
parentf482a29367a3ddbb2111d9df20f8f75b6fa0ca6a (diff)
downloadopenwrt-repro-1779ef7c07a26e7a9e51999066fe55ba85b945b2.tar.gz
openwrt-repro-1779ef7c07a26e7a9e51999066fe55ba85b945b2.zip
script.py template: upgrade to argparse
Conflicts: code/templates/script.py
-rwxr-xr-xcode/templates/script.py14
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: