diff --git a/scripts/libs/shellapi.inc.src b/scripts/libs/shellapi.inc.src new file mode 100644 index 0000000000000000000000000000000000000000..a6d5050b3251ea9d46c8df3d0cfb4ae6a1d5b9e5 --- /dev/null +++ b/scripts/libs/shellapi.inc.src @@ -0,0 +1,57 @@ +// Untested! +// This file has only been merged into master because it depended on the Repo Unification Process +// Which caused a lot of merge conflicts, so reducing merge requests made life easier for everybody at the time + +"#import libs/utils.inc.src" +"#import libs/file.inc.src" + +"#ifbuild" +if not globals.hasIndex("imports") then imports = {} +imports.temp = {} +"#endif" +imports.shellapi = {} +"#ifbuild" +shellapi = imports.shellapi +"#endif" + +imports.shellapi.EXIT = "exit" + +imports.shellapi.constrs = {} + +imports.shellapi.constrs.shellui = function(CMDS) + result = {} + + result.transaction = function() + return [] + end function + result.rollback = function(transaction) + end function + + result.start_terminal = function() + while true + print("Please enter a command:"+imports.file.NEW_LINE) + command = user_prompt().split(" ") + if command[0] == imports.shellapi.EXIT then break + cmd = imports.utils.SafeMapAccess(CMDS,command[0]) + if cmd == null then + print(cmd+ " is not a recognized command") + return + end if + + // Remove the command name + params = [] + for i in range(1,command.len-1) + params.push(command[i]) + end for + + transaction = self.transaction() + result = cmd(self, params) + if result and typeof(result) != "function" then + print(command[0] +" error: "+result) + self.rollback(transaction) + end if + end while + end function + + return result +end function \ No newline at end of file