broke parsing out to a separate command for documentation
parent
8bcfd0329a
commit
c781347bc3
|
@ -1,5 +1,13 @@
|
|||
"""CLI module for converting YAML to tfscript"""
|
||||
# https://www.w3schools.io/file/yaml-arrays/
|
||||
"""
|
||||
Command line module for making Team Fortress 2 macro scripts from
|
||||
YAML source code.
|
||||
"""
|
||||
|
||||
__all__ = ['parseFile']
|
||||
__author__ = "Nicholas Hope <tfscript@nickhope.world"
|
||||
__date__ = "26 August 2022"
|
||||
__version__ = "1.0"
|
||||
__copyright__ = "Copyright © 2022 Nicholas Hope. See LICENSE for details."
|
||||
|
||||
# Standard libraries
|
||||
import sys
|
||||
|
@ -109,10 +117,7 @@ def parseConfig(config):
|
|||
stringToWrite = tfscript.makeCFG(classDict)
|
||||
writeOutput(stringToWrite, currentClass)
|
||||
|
||||
def main():
|
||||
"""Run as a CLI tool"""
|
||||
global args
|
||||
global targetDir
|
||||
def parseCLI():
|
||||
# Handle command line
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Parse YAML file and produce TF2 config script."
|
||||
|
@ -128,6 +133,16 @@ def main():
|
|||
# positional argument: first non-hyphenated argument is input file
|
||||
parser.add_argument( 'infile', type=argparse.FileType('r'),
|
||||
help='File containing YAML to convert.')
|
||||
return parser
|
||||
|
||||
def main():
|
||||
"""
|
||||
Command line interface.
|
||||
"""
|
||||
global args
|
||||
global targetDir
|
||||
parser = parseCLI()
|
||||
|
||||
args = parser.parse_args()
|
||||
if args.directory is not None:
|
||||
targetDir = args.directory
|
||||
|
|
Loading…
Reference in New Issue