Last active
April 19, 2021 17:18
-
-
Save GuilhermeSantos001/ba827b8d93715284f354e87ecbd67c01 to your computer and use it in GitHub Desktop.
Conversão complexa de uma lista de comandos passados por string, por exemplo: debug on color tasks welcome. O script irá executar this.enableDebug("color", "tasks", "welcome");
This file contains hidden or 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
| let command = answers['command'].toLowerCase(), | |
| args = command.split(' ').slice(1), | |
| params = args.slice(1); | |
| if (command.search(/[debug]/g) == 0) { | |
| if (args[0] === 'on') { | |
| let join = params.join(','), | |
| i = 0, l = join.length, quote = false, | |
| newJoin = '\"'; | |
| if (join.indexOf(',') != -1) { | |
| for (; i < l; i++) { | |
| let letter = join[i]; | |
| if (letter != ',') { | |
| if (quote) { | |
| newJoin += `\"`; | |
| quote = false; | |
| } | |
| newJoin += `${join[i]}`; | |
| } else { | |
| quote = true; | |
| newJoin += `\",`; | |
| } | |
| if (i + 1 >= l) | |
| newJoin += `\"`; | |
| } | |
| } else { | |
| newJoin += `${join}\"`; | |
| } | |
| let func = `this.enableDebug(${newJoin});`; | |
| try { | |
| eval(func); | |
| } catch (error) { | |
| console.error(error); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment