Skip to contentSkip to conversation

wic: Add argv argument to main

PATCH New Ed Bartosh 1 participant 1 message Apr 9, 2015

lore
Share & tools
lore

Ed Bartosh

author
#0 lore raw

PATCH 1/1 wic: Add argv argument to main

Make it possible to call wic as an API from tests passing command line parameters as arguments to main.

This is yet another enabler for wic unit testing.

---
 scripts/wic | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
scripts/wic +3 -3
index fd4a678..5bedd90 100755
@@ -279,13 +279,13 @@ def start_logging(loglevel):
     logging.basicConfig(filname='wic.log', filemode='w', level=loglevel)
 
 
-def main():
+def main(argv):
     parser = optparse.OptionParser(version="wic version %s" % __version__,
                                    usage=wic_usage)
 
     parser.disable_interspersed_args()
 
-    (options, args) = parser.parse_args()
+    (options, args) = parser.parse_args(argv)
 
     if len(args):
         if args[0] == "help":
@@ -298,7 +298,7 @@ def main():
 
 if __name__ == "__main__":
     try:
-        ret = main()
+        ret = main(sys.argv[1:])
     except Exception:
         ret = 1
         import traceback
Signature · 1 line
2.1.4