diff --git a/parse_hlds.py b/app/parse_hlds.py similarity index 85% rename from parse_hlds.py rename to app/parse_hlds.py index 6a6961f..8fb08ee 100755 --- a/parse_hlds.py +++ b/app/parse_hlds.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 from tatsu.util import asjson -from app.hlds.parser import parse_files +from hlds.parser import parse_files USAGE = """{0} [filename]... @@ -17,7 +17,7 @@ def main(filenames): if filenames: location_definitions = parse_files(filenames) else: - from app.hlds.definitions import location_definitions + from hlds.definitions import location_definitions print("\n\n".join(map(str, location_definitions))) diff --git a/parse_hlds.sh b/parse_hlds.sh new file mode 100755 index 0000000..b0c3188 --- /dev/null +++ b/parse_hlds.sh @@ -0,0 +1,16 @@ +#!/bin/bash +set -euo pipefail + +# args = map(lambda arg: arg if x[0] in "/-" else pwd+arg, sys.argv[1:]) +args=() +for i in "$@"; do + # If argument is not an option and not an absolute path, it's a relative path: prepend current + # working directory + case "$i" in + /*|-*) args[${#args[@]}]="$i"; ;; + *) args[${#args[@]}]="$PWD/$i"; ;; + esac +done + +cd "$(dirname "$0")/app" +exec ../venv/bin/python parse_hlds.py "${args[@]}"