diff options
Diffstat (limited to 'client.py')
-rwxr-xr-x | client.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/client.py b/client.py new file mode 100755 index 0000000..28b9c45 --- /dev/null +++ b/client.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python +import os +import sys +import requests + +def main(arg=None): + repo = os.getenv("HELLO_REPO") + assert repo is not None, "No repo configured!" + + templates = [] + for t in requests.get(repo).json(): + templates.append(t['name']) + + if arg is None: + return templates + + if arg in templates: + url = "{0}/{1}".format(repo.rstrip("/"), arg) + template = requests.get(url).text + return template + else: + error = "Template for {0} not found".format(arg) + raise Exception(error) + + +if __name__ == '__main__': + print(main(sys.argv[1])) |