diff martini/main.py @ 1:5627074cd79b

* adding ini-munge command * bumping version
author k0s <k0scist@gmail.com>
date Tue, 08 Dec 2009 15:43:16 -0500
parents 3c3522ce6e3a
children d172c078f4a2
line wrap: on
line diff
--- a/martini/main.py	Tue Dec 08 15:13:28 2009 -0500
+++ b/martini/main.py	Tue Dec 08 15:43:16 2009 -0500
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 
-usage = "martini file1 [file2] [...] --section1 option1=value1 option2=value2 --section2 option3=value3"
+usage = "%s file1 [file2] [...] --section1 option1=value1 option2=value2 --section2 option3=value3"
 
 import config
 import os
@@ -61,7 +61,7 @@
     # display usage information
     if not files:
         print 'Usage:'
-        print usage
+        print usage % sys.argv[0]
         sys.exit(0)
 
     # process the files
@@ -89,7 +89,7 @@
     # display usage information
     if not files:
         print 'Usage:'
-        print usage
+        print usage % sys.argv[0]
         sys.exit(0)
 
     # process the files
@@ -119,7 +119,7 @@
     # display usage information
     if not files:
         print 'Usage:'
-        print usage
+        print usage % sys.argv[0]
         sys.exit(0)
 
     # process the files
@@ -144,6 +144,24 @@
             fp = file(f, 'w')
         config.ConfigMunger(conf).write(fp)
 
+def munge(args=None):
+
+    # process arguments
+    if args is None:
+        args = sys.argv[1:]
+    files, sections = parse_options(*args)
+
+    # display usage information
+    if not files:
+        print 'Usage:'
+        print usage % sys.argv[0]
+        sys.exit(0)
+
+    # munge the files
+    conf = list(files) 
+    conf.append(sections)
+    munger = config.ConfigMunger(*conf)
+    munger.write(sys.stdout)
  
 if __name__ == '__main__':
     set(sys.argv[1:])