Created
August 7, 2019 20:02
-
-
Save Jadens-arc/0ed22080630dadb7995cb95ca0a29475 to your computer and use it in GitHub Desktop.
This is a simple code running machine that will let you run your code in the terminal and even create shortcuts if there is a file that you constantly run. Do with it as you wish and feel free to suggest changes
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
import os | |
# welcome to my simple code running machine feel free to change code or add your own shortcuts! | |
supportedLang = ['cd to change working directory', 'quit to quit', 'Python', 'Python3', 'Java'] | |
Dir = "" | |
def userSelect(): | |
global Dir | |
userIn = input("what is the programming language you would like to use? \nSay help to see avalible languages\n") | |
if userIn == "help" or userIn == "?": | |
for langs in supportedLang: | |
print(langs) | |
userSelect() | |
elif userIn.lower() == "cd": | |
Dir = input('what is your working directory\n') | |
userSelect() | |
elif userIn.lower() == "python3" or userIn.lower() == "py3": | |
if Dir == "": | |
runCmdUpper = "python3 " | |
else: | |
runCmdUpper = "cd " + Dir + " && python3 " | |
runCmdLower = input("what is the name of the file including the extention at the end\n") | |
runCmd = runCmdUpper + runCmdLower | |
os.system(runCmd) | |
result = os.system(runCmd) | |
print(result) | |
userSelect() | |
elif userIn.lower() == "python" or userIn.lower() == "py": | |
if Dir == "": | |
runCmdUpper = "python " | |
else: | |
runCmdUpper = "cd " + Dir + " && python " | |
runCmdLower = input("what is the name of the file including the extention at the end\n") | |
runCmd = runCmdUpper + runCmdLower | |
os.system(runCmd) | |
result = os.system(runCmd) | |
print(result) | |
userSelect() | |
elif userIn.lower() == "java": | |
fileName = input('what is the name of your file\n') | |
if Dir == "": | |
runCmd = "javac " + fileName + ".java && java " + fileName | |
else: | |
runCmd = "cd " + Dir + " && javac " + fileName + ".java && java " + fileName | |
result = os.system(runCmd) | |
print(result) | |
userSelect() | |
elif userIn.lower() == " ": | |
# this is an example of a quick short cut feel free to add your own :) | |
runCmd = "javac jaden.java && java jaden" | |
result = os.system(runCmd) | |
print(result) | |
userSelect() | |
elif userIn.lower() == "quit": | |
print('bye') | |
else: | |
print('error', userIn, ' not in system') | |
userSelect() | |
userSelect() | |
# BY Jaden Arceneaux |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment