Added argparse to example_generator.py

This commit is contained in:
Ian Bell
2015-03-13 19:24:12 -06:00
parent 73d4ebca06
commit a51e2af03d

View File

@@ -639,4 +639,16 @@ class Csharp(BaseParser):
return 'using System;\nusing System.Collections.Generic;\nusing System.Text;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n static void Main(string[] args)\n {'
def footer(self):
return '\n }\n }\n}'
return '\n }\n }\n}'
if __name__=='__main__':
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("language", help="The target language (Python, Java, Csharp, etc.)")
parser.add_argument("destination", help="The path to the output file")
args = parser.parse_args()
writer = locals()[args.language]()
writer.write(args.destination, writer.parse())
print 'written to', args.destination