diff --git a/tildetown/mustache.py b/tildetown/mustache.py index be13ea8..0c3f322 100644 --- a/tildetown/mustache.py +++ b/tildetown/mustache.py @@ -15,11 +15,16 @@ def slurp(file_path): pass return contents -def main(argv): +# when you install scripts with entry_points in a setup.py, the resulting +# executable just calls main() and you have to look up sys.argv yourself. I like to explicitly take an argv in my actual main, hence the weird indirection. could probably be better. +def _main(argv): template = slurp(argv[1]) data = json.loads(sys.stdin.read()) sys.stdout.write(render(template, data)) -if __name__ == '__main__': - exit(main(sys.argv)) +def main(): + _main(sys.argv) + +if __name__ == '__main__': + exit(_main(sys.argv))