mirror of https://gitee.com/bigwinds/arangodb
fix UTF-8 console output in Windows
This commit is contained in:
parent
46a295ba43
commit
fb08211ac9
|
@ -7,8 +7,7 @@ break=off
|
||||||
setlocal enableextensions
|
setlocal enableextensions
|
||||||
|
|
||||||
|
|
||||||
SET ACTION_DIR=".\js\actions\demo"
|
SET ACTION_DIR=".\js\actions"
|
||||||
SET ACTION_SYS_DIR=".\js\actions\system"
|
|
||||||
SET GC=20
|
SET GC=20
|
||||||
SET STARTUP_MOD=".\js\server\modules;.\js\common\modules;.\js\node"
|
SET STARTUP_MOD=".\js\server\modules;.\js\common\modules;.\js\node"
|
||||||
SET STARTUP_DIR=".\js"
|
SET STARTUP_DIR=".\js"
|
||||||
|
@ -16,8 +15,6 @@ SET APP_PATH=".\js\apps"
|
||||||
SET PACKAGE_PATH=".\js\npm"
|
SET PACKAGE_PATH=".\js\npm"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SET DATABASE_DIR=".\data"
|
SET DATABASE_DIR=".\data"
|
||||||
SET HTTP_PORT=tcp://127.0.0.1:8529
|
SET HTTP_PORT=tcp://127.0.0.1:8529
|
||||||
SET LOG_LEVEL=info
|
SET LOG_LEVEL=info
|
||||||
|
@ -40,12 +37,12 @@ if NOT EXIST ".\data" (
|
||||||
:: # This indicates abnormal termination.
|
:: # This indicates abnormal termination.
|
||||||
:: ##################################################################
|
:: ##################################################################
|
||||||
|
|
||||||
if EXIST ".\data\lock" goto DEL_LOCK
|
if EXIST ".\data\LOCK" goto DEL_LOCK
|
||||||
|
|
||||||
:DEL_LOCK
|
:DEL_LOCK
|
||||||
echo removing lock file
|
echo removing lock file
|
||||||
del /F .\data\lock > NUL
|
del /F .\data\LOCK > NUL
|
||||||
if EXIST ".\data\lock" (
|
if EXIST ".\data\LOCK" (
|
||||||
echo =======================================================================================
|
echo =======================================================================================
|
||||||
echo ERROR: There appears to be a lock file which is in use. This is generally caused
|
echo ERROR: There appears to be a lock file which is in use. This is generally caused
|
||||||
echo by starting a second server instance before the first instance has terminated.
|
echo by starting a second server instance before the first instance has terminated.
|
||||||
|
@ -70,7 +67,7 @@ SET CMD=%CMD% --database.directory %DATABASE_DIR%
|
||||||
SET CMD=%CMD% --server.disable-authentication true
|
SET CMD=%CMD% --server.disable-authentication true
|
||||||
SET CMD=%CMD% --log.level %LOG_LEVEL%
|
SET CMD=%CMD% --log.level %LOG_LEVEL%
|
||||||
SET CMD=%CMD% --log.severity human
|
SET CMD=%CMD% --log.severity human
|
||||||
SET CMD=%CMD% --javascript.action-directory %ACTION_SYS_DIR%
|
SET CMD=%CMD% --javascript.action-directory %ACTION_DIR%
|
||||||
SET CMD=%CMD% --javascript.modules-path %STARTUP_MOD%
|
SET CMD=%CMD% --javascript.modules-path %STARTUP_MOD%
|
||||||
SET CMD=%CMD% --javascript.startup-directory %STARTUP_DIR%
|
SET CMD=%CMD% --javascript.startup-directory %STARTUP_DIR%
|
||||||
SET CMD=%CMD% --javascript.app-path %APP_PATH%
|
SET CMD=%CMD% --javascript.app-path %APP_PATH%
|
||||||
|
@ -81,14 +78,12 @@ SET CMD=%CMD% --scheduler.threads 4
|
||||||
:: SET CMD=%CMD% --database.maximal-journal-size 1048576
|
:: SET CMD=%CMD% --database.maximal-journal-size 1048576
|
||||||
SET CMD=%CMD% --console
|
SET CMD=%CMD% --console
|
||||||
|
|
||||||
|
SET CMD=%CMD% %*
|
||||||
|
|
||||||
echo starting arangod.exe in server mode
|
echo starting arangod.exe in server mode
|
||||||
echo with %CMD%
|
echo with %CMD%
|
||||||
|
|
||||||
arangod.exe %CMD%
|
arangod.exe %CMD%
|
||||||
goto END
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
:END
|
:END
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
@echo off
|
||||||
|
:: #################################################################
|
||||||
|
:: # script to start the foxx manager in windows
|
||||||
|
:: #################################################################
|
||||||
|
cls
|
||||||
|
break=off
|
||||||
|
setlocal enableextensions
|
||||||
|
|
||||||
|
SET STARTUP_MOD=".\js\client\modules;.\js\common\modules;.\js\node"
|
||||||
|
SET STARTUP_DIR=".\js"
|
||||||
|
SET PACKAGE_PATH=".\js\npm"
|
||||||
|
|
||||||
|
SET HTTP_PORT=tcp://127.0.0.1:8529
|
||||||
|
SET LOG_LEVEL=info
|
||||||
|
|
||||||
|
|
||||||
|
:START_ARANGO
|
||||||
|
:: ##################################################################
|
||||||
|
:: # set the command line parameters
|
||||||
|
:: # If you wish to start the shell without a connection to an
|
||||||
|
:: # server, please change the the command
|
||||||
|
:: # SET CMD=%CMD% --server.endpoint %HTTP_PORT%
|
||||||
|
:: # to
|
||||||
|
:: # SET CMD=%CMD% --server.endpoint none
|
||||||
|
:: ##################################################################
|
||||||
|
|
||||||
|
SET CMD=
|
||||||
|
SET CMD=%CMD% --server.endpoint %HTTP_PORT%
|
||||||
|
SET CMD=%CMD% --server.disable-authentication true
|
||||||
|
SET CMD=%CMD% --log.level %LOG_LEVEL%
|
||||||
|
SET CMD=%CMD% --javascript.startup-directory %STARTUP_DIR%
|
||||||
|
SET CMD=%CMD% --javascript.modules-path %STARTUP_MOD%
|
||||||
|
SET CMD=%CMD% --javascript.package-path %PACKAGE_PATH%
|
||||||
|
SET CMD=%CMD% --javascript.execute-string "require(\"org/arangodb/foxx/manager\").run(ARGUMENTS);"
|
||||||
|
|
||||||
|
SET CMD=%CMD% %*
|
||||||
|
|
||||||
|
echo starting arangosh.exe
|
||||||
|
echo with %CMD%
|
||||||
|
|
||||||
|
arangosh.exe %CMD%
|
|
@ -8,7 +8,6 @@ setlocal enableextensions
|
||||||
|
|
||||||
|
|
||||||
SET ACTION_DIR=".\js\actions"
|
SET ACTION_DIR=".\js\actions"
|
||||||
SET GC=20
|
|
||||||
SET STARTUP_MOD=".\js\server\modules;.\js\common\modules;.\js\node"
|
SET STARTUP_MOD=".\js\server\modules;.\js\common\modules;.\js\node"
|
||||||
SET STARTUP_DIR=".\js"
|
SET STARTUP_DIR=".\js"
|
||||||
SET APP_PATH=".\js\apps"
|
SET APP_PATH=".\js\apps"
|
||||||
|
@ -38,12 +37,12 @@ if NOT EXIST ".\data" (
|
||||||
:: # This indicates abnormal termination.
|
:: # This indicates abnormal termination.
|
||||||
:: ##################################################################
|
:: ##################################################################
|
||||||
|
|
||||||
if EXIST ".\data\lock" goto DEL_LOCK
|
if EXIST ".\data\LOCK" goto DEL_LOCK
|
||||||
|
|
||||||
:DEL_LOCK
|
:DEL_LOCK
|
||||||
echo removing lock file
|
echo removing lock file
|
||||||
del /F .\data\lock > NUL
|
del /F .\data\LOCK > NUL
|
||||||
if EXIST ".\data\lock" (
|
if EXIST ".\data\LOCK" (
|
||||||
echo =======================================================================================
|
echo =======================================================================================
|
||||||
echo ERROR: There appears to be a lock file which is in use. This is generally caused
|
echo ERROR: There appears to be a lock file which is in use. This is generally caused
|
||||||
echo by starting a second server instance before the first instance has terminated.
|
echo by starting a second server instance before the first instance has terminated.
|
||||||
|
@ -78,14 +77,11 @@ SET CMD=%CMD% --scheduler.threads 4
|
||||||
:: the default size is 32M change this if required - especially in the 32 bit version
|
:: the default size is 32M change this if required - especially in the 32 bit version
|
||||||
:: SET CMD=%CMD% --database.maximal-journal-size 1048576
|
:: SET CMD=%CMD% --database.maximal-journal-size 1048576
|
||||||
|
|
||||||
|
SET CMD=%CMD% %*
|
||||||
|
|
||||||
echo starting arangod.exe in server mode
|
echo starting arangod.exe in server mode
|
||||||
echo with %CMD%
|
echo with %CMD%
|
||||||
|
|
||||||
arangod.exe %CMD%
|
arangod.exe %CMD%
|
||||||
goto END
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
:END
|
:END
|
||||||
|
|
||||||
|
|
|
@ -6,16 +6,10 @@ cls
|
||||||
break=off
|
break=off
|
||||||
setlocal enableextensions
|
setlocal enableextensions
|
||||||
|
|
||||||
|
|
||||||
SET ACTION_DIR=".\js\actions\demo"
|
|
||||||
SET ACTION_SYS_DIR=".\js\actions\system"
|
|
||||||
SET GC=20
|
|
||||||
SET STARTUP_MOD=".\js\client\modules;.\js\common\modules;.\js\node"
|
SET STARTUP_MOD=".\js\client\modules;.\js\common\modules;.\js\node"
|
||||||
SET STARTUP_DIR=".\js"
|
SET STARTUP_DIR=".\js"
|
||||||
SET PACKAGE_PATH=".\js\npm"
|
SET PACKAGE_PATH=".\js\npm"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SET HTTP_PORT=tcp://127.0.0.1:8529
|
SET HTTP_PORT=tcp://127.0.0.1:8529
|
||||||
SET LOG_LEVEL=info
|
SET LOG_LEVEL=info
|
||||||
|
|
||||||
|
@ -38,15 +32,9 @@ SET CMD=%CMD% --javascript.startup-directory %STARTUP_DIR%
|
||||||
SET CMD=%CMD% --javascript.modules-path %STARTUP_MOD%
|
SET CMD=%CMD% --javascript.modules-path %STARTUP_MOD%
|
||||||
SET CMD=%CMD% --javascript.package-path %PACKAGE_PATH%
|
SET CMD=%CMD% --javascript.package-path %PACKAGE_PATH%
|
||||||
|
|
||||||
|
SET CMD=%CMD% %*
|
||||||
|
|
||||||
echo starting arangosh.exe
|
echo starting arangosh.exe
|
||||||
echo with %CMD%
|
echo with %CMD%
|
||||||
|
|
||||||
arangosh.exe %CMD%
|
arangosh.exe %CMD%
|
||||||
goto END
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
:END
|
|
||||||
|
|
||||||
|
|
|
@ -8,15 +8,12 @@ setlocal enableextensions
|
||||||
|
|
||||||
|
|
||||||
SET ACTION_DIR=".\js\actions"
|
SET ACTION_DIR=".\js\actions"
|
||||||
SET GC=20
|
|
||||||
SET STARTUP_MOD=".\js\server\modules;.\js\common\modules;.\js\node"
|
SET STARTUP_MOD=".\js\server\modules;.\js\common\modules;.\js\node"
|
||||||
SET STARTUP_DIR=".\js"
|
SET STARTUP_DIR=".\js"
|
||||||
SET APP_PATH=".\js\apps"
|
SET APP_PATH=".\js\apps"
|
||||||
SET PACKAGE_PATH=".\js\npm"
|
SET PACKAGE_PATH=".\js\npm"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SET DATABASE_DIR=".\data"
|
SET DATABASE_DIR=".\data"
|
||||||
SET HTTP_PORT=tcp://127.0.0.1:8529
|
SET HTTP_PORT=tcp://127.0.0.1:8529
|
||||||
SET LOG_LEVEL=info
|
SET LOG_LEVEL=info
|
||||||
|
@ -39,12 +36,12 @@ if NOT EXIST ".\data" (
|
||||||
:: # This indicates abnormal termination.
|
:: # This indicates abnormal termination.
|
||||||
:: ##################################################################
|
:: ##################################################################
|
||||||
|
|
||||||
if EXIST ".\data\lock" goto DEL_LOCK
|
if EXIST ".\data\LOCK" goto DEL_LOCK
|
||||||
|
|
||||||
:DEL_LOCK
|
:DEL_LOCK
|
||||||
echo removing lock file
|
echo removing lock file
|
||||||
del /F .\data\lock > NUL
|
del /F .\data\LOCK > NUL
|
||||||
if EXIST ".\data\lock" (
|
if EXIST ".\data\LOCK" (
|
||||||
echo =======================================================================================
|
echo =======================================================================================
|
||||||
echo ERROR: There appears to be a lock file which is in use. This is generally caused
|
echo ERROR: There appears to be a lock file which is in use. This is generally caused
|
||||||
echo by starting a second server instance before the first instance has terminated.
|
echo by starting a second server instance before the first instance has terminated.
|
||||||
|
@ -81,14 +78,12 @@ SET CMD=%CMD% --scheduler.threads 4
|
||||||
SET CMD=%CMD% --console
|
SET CMD=%CMD% --console
|
||||||
SET CMD=%CMD% --upgrade
|
SET CMD=%CMD% --upgrade
|
||||||
|
|
||||||
|
SET CMD=%CMD% %*
|
||||||
|
|
||||||
echo starting arangod.exe in server mode
|
echo starting arangod.exe in server mode
|
||||||
echo with %CMD%
|
echo with %CMD%
|
||||||
|
|
||||||
arangod.exe %CMD%
|
arangod.exe %CMD%
|
||||||
goto END
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
:END
|
:END
|
||||||
|
|
||||||
|
|
|
@ -392,7 +392,7 @@ void ArangoClient::parse (ProgramOptions& options,
|
||||||
// no password given on command-line
|
// no password given on command-line
|
||||||
if (! _hasPassword) {
|
if (! _hasPassword) {
|
||||||
usleep(10 * 1000);
|
usleep(10 * 1000);
|
||||||
cout << "Please specify a password: " << flush;
|
printContinuous("Please specify a password: ");
|
||||||
|
|
||||||
// now prompt for it
|
// now prompt for it
|
||||||
#ifdef TRI_HAVE_TERMIOS_H
|
#ifdef TRI_HAVE_TERMIOS_H
|
||||||
|
@ -403,11 +403,47 @@ void ArangoClient::parse (ProgramOptions& options,
|
||||||
#else
|
#else
|
||||||
getline(cin, _password);
|
getline(cin, _password);
|
||||||
#endif
|
#endif
|
||||||
cout << "\n";
|
printLine("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief print a string and a newline to stderr
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void ArangoClient::printErrLine (const string& s) {
|
||||||
|
#ifdef _WIN32
|
||||||
|
// no, we can use std::cerr as this doesn't support UTF-8 on Windows
|
||||||
|
fprintf(stderr, "%s\r\n", s.c_str());
|
||||||
|
#else
|
||||||
|
fprintf(stderr, "%s\n", s.c_str());
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief print a string and a newline to stdout
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void ArangoClient::printLine (const string& s) {
|
||||||
|
#ifdef _WIN32
|
||||||
|
// no, we can use std::cout as this doesn't support UTF-8 on Windows
|
||||||
|
fprintf(stdout, "%s\r\n", s.c_str());
|
||||||
|
#else
|
||||||
|
fprintf(stdout, "%s\n", s.c_str());
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief print a string to stdout, without a newline
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void ArangoClient::printContinuous (const string& s) {
|
||||||
|
// no, we can use std::cout as this doesn't support UTF-8 on Windows
|
||||||
|
fprintf(stdout, "%s", s.c_str());
|
||||||
|
fflush(stdout);
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief starts pager
|
/// @brief starts pager
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -501,11 +537,15 @@ void ArangoClient::internalPrint (const char* format, const char* str) {
|
||||||
void ArangoClient::openLog () {
|
void ArangoClient::openLog () {
|
||||||
if (! _logFile.empty()) {
|
if (! _logFile.empty()) {
|
||||||
_log = fopen(_logFile.c_str(), "w");
|
_log = fopen(_logFile.c_str(), "w");
|
||||||
|
|
||||||
|
ostringstream s;
|
||||||
if (_log == 0) {
|
if (_log == 0) {
|
||||||
cerr << "Cannot open file '" << _logFile << "' for logging." << endl;
|
s << "Cannot open file '" << _logFile << "' for logging.";
|
||||||
|
printErrLine(s.str());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
cout << "Logging input and output to '" << _logFile << "'." << endl;
|
s << "Logging input and output to '" << _logFile << "'.";
|
||||||
|
printLine(s.str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -527,11 +567,14 @@ void ArangoClient::closeLog () {
|
||||||
|
|
||||||
void ArangoClient::printWelcomeInfo () {
|
void ArangoClient::printWelcomeInfo () {
|
||||||
if (_usePager) {
|
if (_usePager) {
|
||||||
cout << "Using pager '" << _outputPager << "' for output buffering." << endl;
|
ostringstream s;
|
||||||
|
s << "Using pager '" << _outputPager << "' for output buffering.";
|
||||||
|
|
||||||
|
printLine(s.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_prettyPrint) {
|
if (_prettyPrint) {
|
||||||
cout << "Pretty printing values." << endl;
|
printLine("Pretty printing values.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -541,7 +584,8 @@ void ArangoClient::printWelcomeInfo () {
|
||||||
|
|
||||||
void ArangoClient::printByeBye () {
|
void ArangoClient::printByeBye () {
|
||||||
if (! _quiet) {
|
if (! _quiet) {
|
||||||
cout << "<ctrl-D>" << endl << TRI_BYE_MESSAGE << endl;
|
printLine("<ctrl-D>");
|
||||||
|
printLine(TRI_BYE_MESSAGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -211,6 +211,24 @@ namespace triagens {
|
||||||
char* argv[],
|
char* argv[],
|
||||||
string const& initFilename);
|
string const& initFilename);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief print a string and a newline to stderr, necessary for Windows
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void printErrLine (const std::string&);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief print a string and a newline to stdout, necessary for Windows
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void printLine (const std::string&);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief print a string to stdout, without a newline, necessary for Windows
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void printContinuous (const std::string&);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief starts pager
|
/// @brief starts pager
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -294,9 +294,9 @@ static v8::Handle<v8::Value> JS_ImportCsvFile (v8::Arguments const& argv) {
|
||||||
|
|
||||||
if (ih.importDelimited(collectionName, fileName, ImportHelper::CSV)) {
|
if (ih.importDelimited(collectionName, fileName, ImportHelper::CSV)) {
|
||||||
v8::Handle<v8::Object> result = v8::Object::New();
|
v8::Handle<v8::Object> result = v8::Object::New();
|
||||||
result->Set(v8::String::New("lines"), v8::Integer::New(ih.getReadLines()));
|
result->Set(v8::String::New("lines"), v8::Integer::New((int32_t) ih.getReadLines()));
|
||||||
result->Set(v8::String::New("created"), v8::Integer::New(ih.getImportedLines()));
|
result->Set(v8::String::New("created"), v8::Integer::New((int32_t) ih.getImportedLines()));
|
||||||
result->Set(v8::String::New("errors"), v8::Integer::New(ih.getErrorLines()));
|
result->Set(v8::String::New("errors"), v8::Integer::New((int32_t) ih.getErrorLines()));
|
||||||
return scope.Close(result);
|
return scope.Close(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -340,9 +340,9 @@ static v8::Handle<v8::Value> JS_ImportJsonFile (v8::Arguments const& argv) {
|
||||||
|
|
||||||
if (ih.importJson(collectionName, fileName)) {
|
if (ih.importJson(collectionName, fileName)) {
|
||||||
v8::Handle<v8::Object> result = v8::Object::New();
|
v8::Handle<v8::Object> result = v8::Object::New();
|
||||||
result->Set(v8::String::New("lines"), v8::Integer::New(ih.getReadLines()));
|
result->Set(v8::String::New("lines"), v8::Integer::New((int32_t) ih.getReadLines()));
|
||||||
result->Set(v8::String::New("created"), v8::Integer::New(ih.getImportedLines()));
|
result->Set(v8::String::New("created"), v8::Integer::New((int32_t) ih.getImportedLines()));
|
||||||
result->Set(v8::String::New("errors"), v8::Integer::New(ih.getErrorLines()));
|
result->Set(v8::String::New("errors"), v8::Integer::New((int32_t) ih.getErrorLines()));
|
||||||
return scope.Close(result);
|
return scope.Close(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -543,9 +543,11 @@ static v8::Handle<v8::Value> ClientConnection_ConstructorCallback (v8::Arguments
|
||||||
V8ClientConnection* connection = CreateConnection();
|
V8ClientConnection* connection = CreateConnection();
|
||||||
|
|
||||||
if (connection->isConnected() && connection->getLastHttpReturnCode() == HttpResponse::OK) {
|
if (connection->isConnected() && connection->getLastHttpReturnCode() == HttpResponse::OK) {
|
||||||
cout << "Connected to ArangoDB '" << BaseClient.endpointServer()->getSpecification()
|
ostringstream s;
|
||||||
<< "', version " << connection->getVersion() << ", database '" << BaseClient.databaseName()
|
s << "Connected to ArangoDB '" << BaseClient.endpointServer()->getSpecification()
|
||||||
<< "', username: '" << BaseClient.username() << "'" << endl;
|
<< "', version " << connection->getVersion() << ", database '" << BaseClient.databaseName()
|
||||||
|
<< "', username: '" << BaseClient.username() << "'";
|
||||||
|
BaseClient.printLine(s.str());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
string errorMessage = "Could not connect. Error message: " + connection->getErrorMessage();
|
string errorMessage = "Could not connect. Error message: " + connection->getErrorMessage();
|
||||||
|
@ -586,7 +588,7 @@ static v8::Handle<v8::Value> ClientConnection_reconnect (v8::Arguments const& ar
|
||||||
|
|
||||||
string password;
|
string password;
|
||||||
if (argv.Length() < 4) {
|
if (argv.Length() < 4) {
|
||||||
cout << "Please specify a password: " << flush;
|
BaseClient.printContinuous("Please specify a password: ");
|
||||||
|
|
||||||
// now prompt for it
|
// now prompt for it
|
||||||
#ifdef TRI_HAVE_TERMIOS_H
|
#ifdef TRI_HAVE_TERMIOS_H
|
||||||
|
@ -597,7 +599,7 @@ static v8::Handle<v8::Value> ClientConnection_reconnect (v8::Arguments const& ar
|
||||||
#else
|
#else
|
||||||
getline(cin, password);
|
getline(cin, password);
|
||||||
#endif
|
#endif
|
||||||
cout << "\n";
|
BaseClient.printLine("");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
password = TRI_ObjectToString(argv[3]);
|
password = TRI_ObjectToString(argv[3]);
|
||||||
|
@ -631,9 +633,12 @@ static v8::Handle<v8::Value> ClientConnection_reconnect (v8::Arguments const& ar
|
||||||
V8ClientConnection* newConnection = CreateConnection();
|
V8ClientConnection* newConnection = CreateConnection();
|
||||||
|
|
||||||
if (newConnection->isConnected() && newConnection->getLastHttpReturnCode() == HttpResponse::OK) {
|
if (newConnection->isConnected() && newConnection->getLastHttpReturnCode() == HttpResponse::OK) {
|
||||||
cout << "Connected to ArangoDB '" << BaseClient.endpointServer()->getSpecification()
|
ostringstream s;
|
||||||
<< "' version: " << newConnection->getVersion() << ", database: '" << BaseClient.databaseName()
|
s << "Connected to ArangoDB '" << BaseClient.endpointServer()->getSpecification()
|
||||||
<< "', username: '" << BaseClient.username() << "'" << endl;
|
<< "' version: " << newConnection->getVersion() << ", database: '" << BaseClient.databaseName()
|
||||||
|
<< "', username: '" << BaseClient.username() << "'";
|
||||||
|
|
||||||
|
BaseClient.printLine(s.str());
|
||||||
|
|
||||||
argv.Holder()->SetInternalField(SLOT_CLASS, v8::External::New(newConnection));
|
argv.Holder()->SetInternalField(SLOT_CLASS, v8::External::New(newConnection));
|
||||||
|
|
||||||
|
@ -653,7 +658,10 @@ static v8::Handle<v8::Value> ClientConnection_reconnect (v8::Arguments const& ar
|
||||||
return scope.Close(v8::True());
|
return scope.Close(v8::True());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
cerr << "Could not connect to endpoint '" << BaseClient.endpointString() << "', username: '" << BaseClient.username() << "'" << endl;
|
ostringstream s;
|
||||||
|
s << "Could not connect to endpoint '" << BaseClient.endpointString() <<
|
||||||
|
"', username: '" << BaseClient.username() << "'";
|
||||||
|
BaseClient.printErrLine(s.str());
|
||||||
|
|
||||||
string errorMsg = "could not connect";
|
string errorMsg = "could not connect";
|
||||||
if (newConnection->getErrorMessage() != "") {
|
if (newConnection->getErrorMessage() != "") {
|
||||||
|
@ -1073,7 +1081,7 @@ static v8::Handle<v8::Value> ClientConnection_getEndpoint (v8::Arguments const&
|
||||||
}
|
}
|
||||||
|
|
||||||
const string endpoint = BaseClient.endpointString();
|
const string endpoint = BaseClient.endpointString();
|
||||||
return scope.Close(v8::String::New(endpoint.c_str(), endpoint.size()));
|
return scope.Close(v8::String::New(endpoint.c_str(), (int) endpoint.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -1250,7 +1258,7 @@ static void RunShell (v8::Handle<v8::Context> context, bool promptError) {
|
||||||
|
|
||||||
console.open(BaseClient.autoComplete());
|
console.open(BaseClient.autoComplete());
|
||||||
|
|
||||||
cout << endl;
|
BaseClient.printLine("");
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
// set up prompts
|
// set up prompts
|
||||||
|
@ -1352,7 +1360,7 @@ static void RunShell (v8::Handle<v8::Context> context, bool promptError) {
|
||||||
// command failed
|
// command failed
|
||||||
string exception(TRI_StringifyV8Exception(&tryCatch));
|
string exception(TRI_StringifyV8Exception(&tryCatch));
|
||||||
|
|
||||||
cerr << exception;
|
BaseClient.printErrLine(exception);
|
||||||
BaseClient.log("%s", exception.c_str());
|
BaseClient.log("%s", exception.c_str());
|
||||||
|
|
||||||
// this will change the prompt for the next round
|
// this will change the prompt for the next round
|
||||||
|
@ -1360,7 +1368,7 @@ static void RunShell (v8::Handle<v8::Context> context, bool promptError) {
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseClient.stopPager();
|
BaseClient.stopPager();
|
||||||
cout << endl;
|
BaseClient.printLine("");
|
||||||
|
|
||||||
BaseClient.log("%s\n", "");
|
BaseClient.log("%s\n", "");
|
||||||
// make sure the last command result makes it into the log file
|
// make sure the last command result makes it into the log file
|
||||||
|
@ -1369,7 +1377,7 @@ static void RunShell (v8::Handle<v8::Context> context, bool promptError) {
|
||||||
|
|
||||||
console.close();
|
console.close();
|
||||||
|
|
||||||
cout << endl;
|
BaseClient.printLine("");
|
||||||
|
|
||||||
BaseClient.printByeBye();
|
BaseClient.printByeBye();
|
||||||
}
|
}
|
||||||
|
@ -1399,7 +1407,7 @@ static bool RunUnitTests (v8::Handle<v8::Context> context) {
|
||||||
TRI_ExecuteJavaScriptString(context, v8::String::New(input), name, true);
|
TRI_ExecuteJavaScriptString(context, v8::String::New(input), name, true);
|
||||||
|
|
||||||
if (tryCatch.HasCaught()) {
|
if (tryCatch.HasCaught()) {
|
||||||
cerr << TRI_StringifyV8Exception(&tryCatch);
|
BaseClient.printErrLine(TRI_StringifyV8Exception(&tryCatch));
|
||||||
ok = false;
|
ok = false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1424,7 +1432,10 @@ static bool RunScripts (v8::Handle<v8::Context> context,
|
||||||
|
|
||||||
for (size_t i = 0; i < scripts.size(); ++i) {
|
for (size_t i = 0; i < scripts.size(); ++i) {
|
||||||
if (! FileUtils::exists(scripts[i])) {
|
if (! FileUtils::exists(scripts[i])) {
|
||||||
cerr << "error: Javascript file not found: '" << scripts[i].c_str() << "'" << endl;
|
ostringstream s;
|
||||||
|
s << "error: Javascript file not found: '" << scripts[i].c_str() << "'";
|
||||||
|
BaseClient.printErrLine(s.str());
|
||||||
|
|
||||||
BaseClient.log("error: Javascript file not found: '%s'\n", scripts[i].c_str());
|
BaseClient.log("error: Javascript file not found: '%s'\n", scripts[i].c_str());
|
||||||
ok = false;
|
ok = false;
|
||||||
break;
|
break;
|
||||||
|
@ -1439,8 +1450,8 @@ static bool RunScripts (v8::Handle<v8::Context> context,
|
||||||
|
|
||||||
if (tryCatch.HasCaught()) {
|
if (tryCatch.HasCaught()) {
|
||||||
string exception(TRI_StringifyV8Exception(&tryCatch));
|
string exception(TRI_StringifyV8Exception(&tryCatch));
|
||||||
|
BaseClient.printErrLine(exception);
|
||||||
|
|
||||||
cerr << exception << endl;
|
|
||||||
BaseClient.log("%s\n", exception.c_str());
|
BaseClient.log("%s\n", exception.c_str());
|
||||||
ok = false;
|
ok = false;
|
||||||
break;
|
break;
|
||||||
|
@ -1464,14 +1475,14 @@ static bool RunString (v8::Handle<v8::Context> context,
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
|
|
||||||
v8::Handle<v8::Value> result = TRI_ExecuteJavaScriptString(context,
|
v8::Handle<v8::Value> result = TRI_ExecuteJavaScriptString(context,
|
||||||
v8::String::New(script.c_str(), script.size()),
|
v8::String::New(script.c_str(), (int) script.size()),
|
||||||
v8::String::New("(command-line)"),
|
v8::String::New("(command-line)"),
|
||||||
false);
|
false);
|
||||||
|
|
||||||
if (tryCatch.HasCaught()) {
|
if (tryCatch.HasCaught()) {
|
||||||
string exception(TRI_StringifyV8Exception(&tryCatch));
|
string exception(TRI_StringifyV8Exception(&tryCatch));
|
||||||
|
|
||||||
cerr << exception << endl;
|
BaseClient.printErrLine(exception);
|
||||||
BaseClient.log("%s\n", exception.c_str());
|
BaseClient.log("%s\n", exception.c_str());
|
||||||
ok = false;
|
ok = false;
|
||||||
}
|
}
|
||||||
|
@ -1516,7 +1527,7 @@ static bool RunJsLint (v8::Handle<v8::Context> context) {
|
||||||
TRI_ExecuteJavaScriptString(context, v8::String::New(input), name, true);
|
TRI_ExecuteJavaScriptString(context, v8::String::New(input), name, true);
|
||||||
|
|
||||||
if (tryCatch.HasCaught()) {
|
if (tryCatch.HasCaught()) {
|
||||||
cerr << TRI_StringifyV8Exception(&tryCatch);
|
BaseClient.printErrLine(TRI_StringifyV8Exception(&tryCatch));
|
||||||
ok = false;
|
ok = false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1642,7 +1653,11 @@ int main (int argc, char* argv[]) {
|
||||||
BaseClient.createEndpoint();
|
BaseClient.createEndpoint();
|
||||||
|
|
||||||
if (BaseClient.endpointServer() == 0) {
|
if (BaseClient.endpointServer() == 0) {
|
||||||
cerr << "invalid value for --server.endpoint ('" << BaseClient.endpointString() << "')" << endl;
|
ostringstream s;
|
||||||
|
s << "invalid value for --server.endpoint ('" << BaseClient.endpointString() << "')";
|
||||||
|
|
||||||
|
BaseClient.printErrLine(s.str());
|
||||||
|
|
||||||
TRI_EXIT_FUNCTION(EXIT_FAILURE,NULL);
|
TRI_EXIT_FUNCTION(EXIT_FAILURE,NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1664,7 +1679,7 @@ int main (int argc, char* argv[]) {
|
||||||
v8::Persistent<v8::Context> context = v8::Context::New(0, global);
|
v8::Persistent<v8::Context> context = v8::Context::New(0, global);
|
||||||
|
|
||||||
if (context.IsEmpty()) {
|
if (context.IsEmpty()) {
|
||||||
cerr << "cannot initialize V8 engine" << endl;
|
BaseClient.printErrLine("cannot initialize V8 engine");
|
||||||
TRI_EXIT_FUNCTION(EXIT_FAILURE,NULL);
|
TRI_EXIT_FUNCTION(EXIT_FAILURE,NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1765,7 +1780,7 @@ int main (int argc, char* argv[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// not sure about the code page
|
// not sure about the code page
|
||||||
//SetConsoleOutputCP(65001);
|
SetConsoleOutputCP(65001);
|
||||||
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), greenColour);
|
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), greenColour);
|
||||||
printf(" ");
|
printf(" ");
|
||||||
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), redColour);
|
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), redColour);
|
||||||
|
@ -1816,7 +1831,7 @@ int main (int argc, char* argv[]) {
|
||||||
z = "";
|
z = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
cout << endl;
|
BaseClient.printLine("");
|
||||||
|
|
||||||
printf("%s %s _ %s\n", g, r, z);
|
printf("%s %s _ %s\n", g, r, z);
|
||||||
printf("%s __ _ _ __ __ _ _ __ __ _ ___ %s ___| |__ %s\n", g, r, z);
|
printf("%s __ _ _ __ __ _ _ __ __ _ ___ %s ___| |__ %s\n", g, r, z);
|
||||||
|
@ -1826,10 +1841,15 @@ int main (int argc, char* argv[]) {
|
||||||
printf("%s |___/ %s %s\n", g, r, z);
|
printf("%s |___/ %s %s\n", g, r, z);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
BaseClient.printLine("");
|
||||||
|
|
||||||
cout << endl << "Welcome to arangosh " << TRI_VERSION_FULL << ". Copyright (c) triAGENS GmbH" << endl;
|
ostringstream s;
|
||||||
|
s << "Welcome to arangosh " << TRI_VERSION_FULL << ". Copyright (c) triAGENS GmbH";
|
||||||
|
|
||||||
|
BaseClient.printLine(s.str());
|
||||||
|
|
||||||
ostringstream info;
|
ostringstream info;
|
||||||
|
info << "Using ";
|
||||||
|
|
||||||
#ifdef TRI_V8_VERSION
|
#ifdef TRI_V8_VERSION
|
||||||
info << "Google V8 " << TRI_V8_VERSION << " JavaScript engine";
|
info << "Google V8 " << TRI_V8_VERSION << " JavaScript engine";
|
||||||
|
@ -1845,27 +1865,36 @@ int main (int argc, char* argv[]) {
|
||||||
info << ", ICU " << TRI_ICU_VERSION;
|
info << ", ICU " << TRI_ICU_VERSION;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
cout << "Using " << info.str() << endl << endl;
|
BaseClient.printLine(info.str());
|
||||||
|
BaseClient.printLine("");
|
||||||
|
|
||||||
BaseClient.printWelcomeInfo();
|
BaseClient.printWelcomeInfo();
|
||||||
|
|
||||||
if (useServer) {
|
if (useServer) {
|
||||||
if (ClientConnection->isConnected() && ClientConnection->getLastHttpReturnCode() == HttpResponse::OK) {
|
if (ClientConnection->isConnected() && ClientConnection->getLastHttpReturnCode() == HttpResponse::OK) {
|
||||||
cout << "Connected to ArangoDB '" << BaseClient.endpointString()
|
ostringstream is;
|
||||||
<< "' version: " << ClientConnection->getVersion() << ", database: '" << BaseClient.databaseName()
|
is << "Connected to ArangoDB '" << BaseClient.endpointString()
|
||||||
<< "', username: '" << BaseClient.username() << "'" << endl;
|
<< "' version: " << ClientConnection->getVersion() << ", database: '" << BaseClient.databaseName()
|
||||||
|
<< "', username: '" << BaseClient.username() << "'";
|
||||||
|
|
||||||
|
BaseClient.printLine(is.str());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
cerr << "Could not connect to endpoint '" << BaseClient.endpointString()
|
ostringstream is;
|
||||||
<< "', database: '" << BaseClient.databaseName()
|
is << "Could not connect to endpoint '" << BaseClient.endpointString()
|
||||||
<< "', username: '" << BaseClient.username() << "'" << endl;
|
<< "', database: '" << BaseClient.databaseName()
|
||||||
|
<< "', username: '" << BaseClient.username() << "'";
|
||||||
|
BaseClient.printErrLine(is.str());
|
||||||
|
|
||||||
if (ClientConnection->getErrorMessage() != "") {
|
if (ClientConnection->getErrorMessage() != "") {
|
||||||
cerr << "Error message '" << ClientConnection->getErrorMessage() << "'" << endl;
|
ostringstream is2;
|
||||||
|
is2 << "Error message '" << ClientConnection->getErrorMessage() << "'";
|
||||||
|
BaseClient.printErrLine(is2.str());
|
||||||
}
|
}
|
||||||
promptError = true;
|
promptError = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
cout << endl;
|
BaseClient.printLine("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1943,10 +1972,10 @@ int main (int argc, char* argv[]) {
|
||||||
// create arguments
|
// create arguments
|
||||||
// .............................................................................
|
// .............................................................................
|
||||||
|
|
||||||
v8::Handle<v8::Array> p = v8::Array::New(positionals.size());
|
v8::Handle<v8::Array> p = v8::Array::New((int) positionals.size());
|
||||||
|
|
||||||
for (size_t i = 0; i < positionals.size(); ++i) {
|
for (uint32_t i = 0; i < positionals.size(); ++i) {
|
||||||
p->Set(i, v8::String::New(positionals[i].c_str()));
|
p->Set(i, v8::String::New(positionals[i].c_str(), (int) positionals[i].size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
TRI_AddGlobalVariableVocbase(context, "ARGUMENTS", p);
|
TRI_AddGlobalVariableVocbase(context, "ARGUMENTS", p);
|
||||||
|
|
Loading…
Reference in New Issue