Files
shexy.src
//command: shexy (shellexec) v0.3.1
- // command: shexy (shellexec) v0.3.6
- // Changelog
// * Added Fullpath and Relatvepath
// * Prepared Binary Mode
// * Added debug messages
// * Reworked Parameters
// * Improved code
// * shex is now called shexy -> shellexec is shexy :-P
- // * Added Debug Message: Build Time and Run Time
- // * Fixed a bug where shexy is located in /bin
- // * Added more checks to search paths
- // * Simplify search paths
- // * Added command line
- DebugOn = 0
- BinaryOn = 0
- filepath = ""
- tocolor = function(color)
- return "<color="+color+">"+self.str+"</color>"
- end function
- convert = function(text)
- obj = {}
- obj.str = str(text)
- obj.tocolor = @tocolor
- return obj
- end function
- debug = function(msg)
- if DebugOn == 1 then
- print( convert("[DEBUG] "+msg).tocolor("purple") )
- end if
- end function
- cmd = function()
- filename = "tmp.src"
- tmp_path = home_dir+"/"+"Cache"
- ful_path = tmp_path+"/"+filename
-
- if typeof(get_shell.host_computer.File(ful_path)) != "file" then
- get_shell.host_computer.create_folder(home_dir,"Cache")
- end if
- get_shell.host_computer.touch(tmp_path,filename)
-
- clear_screen
- print("~ Shexy - Command Line ~")
- print("(Here you can run GreyHackCode.)")
- while true
- input = user_input("> ",false,false)
- get_shell.host_computer.File(ful_path).set_content(input)
- get_shell.build(ful_path,tmp_path,false)
- get_shell.launch(tmp_path+"/"+filename.remove(".src"))
- end while
- end function
- for parm in params
- if parm == "-h" or parm == "--help" then
- exit(launch_path.split("/")[-1]+" [source] [args]")
- end if
- if parm == "-d" then
- DebugOn = 1
- continue
- end if
- if parm == "-c" then
BinaryOn = 1
continue
- cmd()
- exit
- end if
if parm.indexOf("/") == 0 then
if typeof(get_shell.host_computer.File(parm)) != "file" then
debug(parm+" is invalid")
continue
end if
if typeof(get_shell.host_computer.File(parm)) == "file" then
filepath = parm
args = params[1:].join(" ")
break
end if
-
- if parm == "make" then
- read_config()
- exit
- end if
- check_path = function(input)
-
if parm.indexOf("/") != 0 then
p = parent_path(launch_path)+"/"+parm
if typeof(get_shell.host_computer.File(p)) != "file" then
debug(p+" is invalid")
debug("Arguments: "+args)
- for x in input
- NewPath = x
- Object = get_shell.host_computer.File(NewPath)
- Type = typeof(Object)
- if Type != "file" and Type == "null" then
- debug(NewPath+" is "+Type)
- continue
end if
if typeof(get_shell.host_computer.File(p)) == "file" then
filepath = p
args = params[1:].join(" ")
debug("Arguments: "+args)
- else if Type == "file" and Type != "null" then
- debug(NewPath+" is "+Type)
- output = NewPath
- return output
- break
- end if
end if
- end for
-
- end function
-
- Paths = []
- Paths.push(parent_path(launch_path)+"/"+parm)
- Paths.push(parent_path(program_path)+"/"+parm)
- Paths.push(current_path+"/"+parm)
- Paths.push(parm)
-
- filepath = check_path(Paths)
- args = params[1:].join(" ")
- debug("Arguments: "+args)
- end for
- debug("Path: "+filepath)
- if filepath == "" then
- debug("No valid path")
- exit()
- end if
- cache_path = home_dir+"/"+"Cache"+"/"+"shex"
- source = get_shell.host_computer.File(filepath)
if source.is_binary then exit("Target is not a Source File.")
if not source.has_permission("r") then exit("Target has no read permissions.")
if not filepath.indexOf(".src") then exit("Target must have the suffix [*.src].")
- if source.is_binary then
- debug("Target is not a Source File.")
- exit
- else if not source.has_permission("r") then
- debug("Target has no read permissions.")
- exit
- else if not filepath.indexOf(".src") then
- debug("Target must have the suffix [*.src].")
- exit
- end if
- if filepath.indexOf(".src") then
-
- if source != null then
-
if get_shell.host_computer.File(cache_path) == null then
- if typeof(get_shell.host_computer.File(cache_path)) != "file" then
- get_shell.host_computer.create_folder(home_dir,"Cache")
- get_shell.host_computer.create_folder(home_dir+"/"+"Cache","shex")
- end if
-
- src = get_shell.host_computer.File(current_path+"/"+params[0])
- md5sum = md5(get_shell.host_computer.File(filepath).get_content)
- BinName = filepath.split("/")[-1].remove(".src")
- program = cache_path+"/"+BinName+"-"+md5sum
- for file in get_shell.host_computer.File(cache_path).get_files
- FileName = file.name.split("-")[0]
- FileSum = file.name.split("-")[1]
- debug(FileName+"-"+FileSum)
- if FileSum != md5sum and FileName == BinName then
- file.delete
- continue
- end if
- if FileSum == md5sum and FileName == BinName then
- get_shell.launch(file.path, args)
- OnlyRuntime = round(time,2)
- debug("Run Time => "+str(OnlyRuntime)+" sec")
- exit
- end if
- end for
-
- debug("Source file: "+filepath)
- debug("Target Path: "+cache_path)
- print( get_shell.build(filepath,cache_path,false) )
- BinPath = get_shell.host_computer.File(cache_path+"/"+BinName)
- if BinPath != null then
- get_shell.host_computer.File(cache_path+"/"+BinName).rename(BinName+"-"+md5sum)
- BuildTime = round(time,2)
- debug("Build Time => "+str(BuildTime)+" sec")
- else
- exit("File not compiled")
- end if
-
get_shell.launch(cache_path+"/"+BinName+"-"+md5sum, args)
- get_shell.launch(cache_path+"/"+BinName+"-"+md5sum, args)
- RunTime = time
- RunTime = round(RunTime - BuildTime,2)
- debug("Run Time => "+str(RunTime)+" sec")
- exit
-
- end if
-
- end if
end if
- end ifif