haldis/app/parse_hlds.py

33 lines
719 B
Python
Raw Permalink Normal View History

#!/usr/bin/env python3
from tatsu.util import asjson
from hlds.parser import parse_files
USAGE = """{0} [filename]...
Parse HLDS files, print as JSON
Without arguments, parse the default definitions.
With filenames as arguments, parse those files as HLDS.
{} --help Print this help text"""
def main(filenames):
if filenames:
location_definitions = parse_files(filenames)
else:
from hlds.definitions import location_definitions
print("\n\n".join(map(str, location_definitions)))
if __name__ == "__main__":
import sys
2020-07-17 11:40:15 +02:00
args = sys.argv[1:]
if "-h" in args or "--help" in args:
print(USAGE.format(sys.argv[0]), file=sys.stderr)
else:
main(args)