Rearranged code a bit to make it a proper CLI tool

pull/11/head
Paco Hope 2022-08-06 22:14:33 -04:00
parent e5c5b10420
commit 4c9357b270
1 changed files with 10 additions and 4 deletions

View File

@ -10,7 +10,9 @@ import yaml
# Local libraries
import tfscript
import verify
from tfscript import verify
args = {}
def parseFile(inputFile):
"""Parse, verify, and do the conversion."""
@ -89,8 +91,9 @@ def parseConfig(config):
stringToWrite = tfscript.makeCFG(classDict)
writeOutput(stringToWrite, currentClass)
# Main function
if __name__ == "__main__":
def main():
"""Run as a CLI tool"""
global args
# Handle command line
parser = argparse.ArgumentParser(
description="Parse YAML file and produce TF2 config script."
@ -103,4 +106,7 @@ if __name__ == "__main__":
parser.add_argument( 'infile', type=argparse.FileType('r'),
help='File containing YAML to convert.')
args = parser.parse_args()
parseFile(args.infile)
parseFile(args.infile)
if __name__ == "__main__":
main()