| 93 | vector<asIScriptContext*> g_ctxPool; |
| 94 | |
| 95 | int main(int argc, char **argv) |
| 96 | { |
| 97 | #if defined(_WIN32) |
| 98 | // Turn on support for virtual terminal sequences to add support for colored text in the console |
| 99 | // Ref: https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences |
| 100 | // Ref: https://stackoverflow.com/questions/2048509/how-to-echo-with-different-colors-in-the-windows-command-line |
| 101 | HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE); |
| 102 | if (hOut == INVALID_HANDLE_VALUE) |
| 103 | return -1; |
| 104 | |
| 105 | DWORD dwMode = 0; |
| 106 | if (!GetConsoleMode(hOut, &dwMode)) |
| 107 | return -1; |
| 108 | |
| 109 | dwMode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING; |
| 110 | if (!SetConsoleMode(hOut, dwMode)) |
| 111 | return -1; |
| 112 | #endif |
| 113 | |
| 114 | int r; |
| 115 | |
| 116 | // Validate the command line arguments |
| 117 | bool argsValid = true; |
| 118 | if( argc < 2 ) |
| 119 | argsValid = false; |
| 120 | else if( argc == 2 && strcmp(argv[1], "-d") == 0 ) |
| 121 | argsValid = false; |
| 122 | |
| 123 | if( !argsValid ) |
| 124 | { |
| 125 | cout << "AngelScript command line runner. Version " << ANGELSCRIPT_VERSION_STRING << endl << endl; |
| 126 | cout << "Usage: " << endl; |
| 127 | cout << "asrun [-d] <script file> [<args>]" << endl; |
| 128 | cout << " -d inform if the script should be runned with debug" << endl; |
| 129 | cout << " <script file> is the script file that should be runned" << endl; |
| 130 | cout << " <args> zero or more args for the script" << endl; |
| 131 | |
| 132 | WaitForUser(); |
| 133 | return -1; |
| 134 | } |
| 135 | |
| 136 | // Create the script engine |
| 137 | asIScriptEngine *engine = asCreateScriptEngine(); |
| 138 | if( engine == 0 ) |
| 139 | { |
| 140 | cout << "Failed to create script engine." << endl; |
| 141 | return -1; |
| 142 | } |
| 143 | |
| 144 | // Configure the script engine with all the functions, |
| 145 | // and variables that the script should be able to use. |
| 146 | r = ConfigureEngine(engine); |
| 147 | if( r < 0 ) return -1; |
| 148 | |
| 149 | // Check if the script is to be debugged |
| 150 | if( strcmp(argv[1], "-d") == 0 ) |
| 151 | g_doDebug = true; |
| 152 |
nothing calls this directly
no test coverage detected