Last active
October 10, 2015 05:32
-
-
Save ukn-ubi/fa2ff9f15965cf1ac792 to your computer and use it in GitHub Desktop.
A project/build system that currently supports a few languages, will later support other languages. Run `python git-proj.py help` to get help message. It needs virtualenv and assumes a unix based system.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
""" | |
Name: Git-Proj | |
Desc: A git and makefile based project/build system. | |
""" | |
import sys, subprocess, os | |
def main(): | |
""" | |
Main function | |
""" | |
if sys.argv[1] == "new": | |
os.mkdir(sys.argv[2]) | |
os.chdir(sys.argv[2]) | |
subprocess.call(["git init"], shell=True, stdout=subprocess.PIPE) | |
os.mkdir("src") | |
os.mkdir("doc") | |
readme_file = open("README", mode='w') | |
readme = sys.argv[2] +""" | |
================ | |
This thing does stuff. | |
""" | |
readme_file.write(readme) | |
readme_file.close() | |
if sys.argv[3] == "python": | |
open("src/main.py", mode='w').write('print("Hello, World!")') | |
open("build.sh", mode='w').write(""" | |
python src/main.py""") | |
elif sys.argv[3] == "hy": | |
open("src/main.hy", mode='w').write('(print "Hello, World!")') | |
open("build.sh", mode='w').write("hy src/main.hy\nsource dg-virtualenv/bin/activate") | |
subprocess.call(["virtualenv", "hy-virtualenv"]) | |
open("virtualenv-thing.sh", mode='w').write('source hy-virtualenv/bin/activate') | |
subprocess.call(["./hy-virtualenv/bin/pip", "install", "hy"]) | |
elif sys.argv[3] == "dg": | |
open("src/main.dg", mode='w').write('"Hello, World!" |> print') | |
open("build.sh", mode='w').write("python -m dg src/main.dg\nsource dg-virtualenv/bin/activate") | |
subprocess.call(["virtualenv", "dg-virtualenv"]) | |
open("virtualenv-thing.sh", mode='w').write('source dg-virtualenv/bin/activate') | |
subprocess.call(["./dg-virtualenv/bin/pip", "install", "git+https://github.com/pyos/dg"]) | |
# TODO: Add lua support Sat 10 Oct 2015 12:36:17 PM WITA | |
# TODO: Add moonscript support Sat 10 Oct 2015 12:36:28 PM WITA | |
# TODO: Add Ruby support Sat 10 Oct 2015 12:57:14 PM WITA | |
# TODO: Add NodeJS support Sat 10 Oct 2015 12:57:27 PM WITA | |
# TODO: Add C, C++ support Sat 10 Oct 2015 12:57:39 PM WITA | |
# TODO: Add C#, F# support Sat 10 Oct 2015 12:57:57 PM WITA | |
# TODO: Add Web support Sat 10 Oct 2015 12:58:12 PM WITA | |
# TODO: Add OCaml support Sat 10 Oct 2015 12:58:26 PM WITA | |
elif sys.argv[1] == "help": | |
print(""" | |
I'm guessing that you didn't know what to do. | |
Here's a help message: | |
New Project: | |
python git-proj.py new <python/hy/dg> <project-name> | |
Resolve Dependancies: | |
python git-proj.py dep <dep-file> <command> <install-command> | |
Example: | |
python git-proj.py dep pip-deps pip install | |
Find Todos: | |
python git-proj.py todo <file-to-search-for-todos-in> | |
Setup a virtualenv: | |
python git-proj.py setup <virtualenv-name> <bottle/flask/jupyter> | |
""") | |
elif sys.argv[1] == "dep": | |
dep_file = sys.argv[2] | |
dependency_resolver = sys.argv[3] | |
install_command = sys.argv[4] | |
deps = open(dep_file).read() | |
for i in deps.split("\n"): | |
subprocess.call([dependency_resolver, install_command, i]) | |
elif sys.argv[1] == "todo": | |
todo_files = sys.argv[2] | |
file_with_todos = open(todo_files).read() | |
for i in file_with_todos.split("\n"): | |
if "TODO" in i: | |
print(i) | |
elif sys.argv[1] == "setup": | |
name = sys.argv[2] | |
subprocess.call(["virtualenv", name]) | |
if sys.argv[3] == "bottle": | |
subprocess.call(["./" + name + "/bin/pip", "install", "bottle"]) | |
elif sys.argv[3] == "flask": | |
subprocess.call(["./" + name + "/bin/pip", "install", "flask"]) | |
elif sys.argv[3] == "jupyter": | |
subprocess.call(["./" + name + "/bin/pip", "install", "jupyter"]) | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment