From 8b85b1986543445512267ee44c8c23ac7a5052b5 Mon Sep 17 00:00:00 2001 From: LaplongeJunior <laplongejunior@gmail.com> Date: Sun, 2 Aug 2020 12:20:15 +0000 Subject: [PATCH] Added generic shellapi.inc --- scripts/libs/shellapi.inc.src | 57 +++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 scripts/libs/shellapi.inc.src diff --git a/scripts/libs/shellapi.inc.src b/scripts/libs/shellapi.inc.src new file mode 100644 index 0000000..a6d5050 --- /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 -- GitLab