1
0
Fork 0

moved to ArangoClient

This commit is contained in:
Frank Celler 2012-08-31 08:54:40 +02:00
commit 516cfea36b
10 changed files with 86 additions and 344 deletions

View File

@ -738,9 +738,11 @@ bin_arangoimp_OBJECTS = $(am_bin_arangoimp_OBJECTS)
bin_arangoimp_DEPENDENCIES = lib/libarango_v8.a lib/libarango_client.a \
lib/libarango.a $(am__DEPENDENCIES_2)
am__bin_arangoirb_SOURCES_DIST = \
arangosh/ArangoShell/ArangoClient.cpp \
arangoirb/MRClient/MRubyClientConnection.cpp \
arangoirb/MRClient/arangoirb.cpp
@ENABLE_MRUBY_TRUE@am_bin_arangoirb_OBJECTS = arangoirb/MRClient/bin_arangoirb-MRubyClientConnection.$(OBJEXT) \
@ENABLE_MRUBY_TRUE@am_bin_arangoirb_OBJECTS = arangosh/ArangoShell/bin_arangoirb-ArangoClient.$(OBJEXT) \
@ENABLE_MRUBY_TRUE@ arangoirb/MRClient/bin_arangoirb-MRubyClientConnection.$(OBJEXT) \
@ENABLE_MRUBY_TRUE@ arangoirb/MRClient/bin_arangoirb-arangoirb.$(OBJEXT)
bin_arangoirb_OBJECTS = $(am_bin_arangoirb_OBJECTS)
@ENABLE_MRUBY_TRUE@bin_arangoirb_DEPENDENCIES = lib/libarango_mruby.a \
@ -1010,8 +1012,8 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
BUILT_SOURCES = build.h $(JAVASCRIPT_HEADER) $(JAVASCRIPT_BROWSER) \
$(MRUBY_HEADER) etc/arangodb/arangod.conf \
etc/arangodb/arangosh.conf $(am__append_16) \
Documentation/.setup-directories \
etc/arangodb/arangoirb.conf etc/arangodb/arangosh.conf \
$(am__append_16) Documentation/.setup-directories \
@builddir@/.setup-js-directories $(am__append_17) \
$(am__append_19) $(am__append_21) $(PROTOBUF_FILES) \
$(am__append_23) $(am__append_24) $(am__append_25) \
@ -1527,6 +1529,7 @@ bin_arango_upgrade_SOURCES =
bin_arango_dfdb_SOURCES =
@ENABLE_MRUBY_TRUE@bin_arangoirb_CPPFLAGS = \
@ENABLE_MRUBY_TRUE@ -I@top_srcdir@/arangoirb \
@ENABLE_MRUBY_TRUE@ -I@top_srcdir@/arangosh \
@ENABLE_MRUBY_TRUE@ $(AM_CPPFLAGS)
@ENABLE_MRUBY_TRUE@bin_arangoirb_LDADD = \
@ -1537,6 +1540,7 @@ bin_arango_dfdb_SOURCES =
@ENABLE_MRUBY_TRUE@ @MRUBY_LIBS@
@ENABLE_MRUBY_TRUE@bin_arangoirb_SOURCES = \
@ENABLE_MRUBY_TRUE@ arangosh/ArangoShell/ArangoClient.cpp \
@ENABLE_MRUBY_TRUE@ arangoirb/MRClient/MRubyClientConnection.cpp \
@ENABLE_MRUBY_TRUE@ arangoirb/MRClient/arangoirb.cpp
@ -2779,6 +2783,9 @@ arangosh/V8Client/bin_arangoimp-arangoimp.$(OBJEXT): \
bin/arangoimp$(EXEEXT): $(bin_arangoimp_OBJECTS) $(bin_arangoimp_DEPENDENCIES) bin/$(am__dirstamp)
@rm -f bin/arangoimp$(EXEEXT)
$(AM_V_CXXLD)$(CXXLINK) $(bin_arangoimp_OBJECTS) $(bin_arangoimp_LDADD) $(LIBS)
arangosh/ArangoShell/bin_arangoirb-ArangoClient.$(OBJEXT): \
arangosh/ArangoShell/$(am__dirstamp) \
arangosh/ArangoShell/$(DEPDIR)/$(am__dirstamp)
arangoirb/MRClient/$(am__dirstamp):
@$(MKDIR_P) arangoirb/MRClient
@: > arangoirb/MRClient/$(am__dirstamp)
@ -2921,6 +2928,7 @@ mostlyclean-compile:
-rm -f arangoirb/MRClient/bin_arangoirb-MRubyClientConnection.$(OBJEXT)
-rm -f arangoirb/MRClient/bin_arangoirb-arangoirb.$(OBJEXT)
-rm -f arangosh/ArangoShell/bin_arangoimp-ArangoClient.$(OBJEXT)
-rm -f arangosh/ArangoShell/bin_arangoirb-ArangoClient.$(OBJEXT)
-rm -f arangosh/ArangoShell/bin_arangosh-ArangoClient.$(OBJEXT)
-rm -f arangosh/V8Client/bin_arangoimp-ImportHelper.$(OBJEXT)
-rm -f arangosh/V8Client/bin_arangoimp-V8ClientConnection.$(OBJEXT)
@ -3185,6 +3193,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@arangoirb/MRClient/$(DEPDIR)/bin_arangoirb-MRubyClientConnection.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@arangoirb/MRClient/$(DEPDIR)/bin_arangoirb-arangoirb.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@arangosh/ArangoShell/$(DEPDIR)/bin_arangoimp-ArangoClient.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@arangosh/ArangoShell/$(DEPDIR)/bin_arangoirb-ArangoClient.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@arangosh/ArangoShell/$(DEPDIR)/bin_arangosh-ArangoClient.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@arangosh/V8Client/$(DEPDIR)/bin_arangoimp-ImportHelper.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@arangosh/V8Client/$(DEPDIR)/bin_arangoimp-V8ClientConnection.Po@am__quote@
@ -4608,6 +4617,22 @@ arangosh/V8Client/bin_arangoimp-arangoimp.obj: arangosh/V8Client/arangoimp.cpp
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bin_arangoimp_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o arangosh/V8Client/bin_arangoimp-arangoimp.obj `if test -f 'arangosh/V8Client/arangoimp.cpp'; then $(CYGPATH_W) 'arangosh/V8Client/arangoimp.cpp'; else $(CYGPATH_W) '$(srcdir)/arangosh/V8Client/arangoimp.cpp'; fi`
arangosh/ArangoShell/bin_arangoirb-ArangoClient.o: arangosh/ArangoShell/ArangoClient.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bin_arangoirb_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT arangosh/ArangoShell/bin_arangoirb-ArangoClient.o -MD -MP -MF arangosh/ArangoShell/$(DEPDIR)/bin_arangoirb-ArangoClient.Tpo -c -o arangosh/ArangoShell/bin_arangoirb-ArangoClient.o `test -f 'arangosh/ArangoShell/ArangoClient.cpp' || echo '$(srcdir)/'`arangosh/ArangoShell/ArangoClient.cpp
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) arangosh/ArangoShell/$(DEPDIR)/bin_arangoirb-ArangoClient.Tpo arangosh/ArangoShell/$(DEPDIR)/bin_arangoirb-ArangoClient.Po
@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='arangosh/ArangoShell/ArangoClient.cpp' object='arangosh/ArangoShell/bin_arangoirb-ArangoClient.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bin_arangoirb_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o arangosh/ArangoShell/bin_arangoirb-ArangoClient.o `test -f 'arangosh/ArangoShell/ArangoClient.cpp' || echo '$(srcdir)/'`arangosh/ArangoShell/ArangoClient.cpp
arangosh/ArangoShell/bin_arangoirb-ArangoClient.obj: arangosh/ArangoShell/ArangoClient.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bin_arangoirb_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT arangosh/ArangoShell/bin_arangoirb-ArangoClient.obj -MD -MP -MF arangosh/ArangoShell/$(DEPDIR)/bin_arangoirb-ArangoClient.Tpo -c -o arangosh/ArangoShell/bin_arangoirb-ArangoClient.obj `if test -f 'arangosh/ArangoShell/ArangoClient.cpp'; then $(CYGPATH_W) 'arangosh/ArangoShell/ArangoClient.cpp'; else $(CYGPATH_W) '$(srcdir)/arangosh/ArangoShell/ArangoClient.cpp'; fi`
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) arangosh/ArangoShell/$(DEPDIR)/bin_arangoirb-ArangoClient.Tpo arangosh/ArangoShell/$(DEPDIR)/bin_arangoirb-ArangoClient.Po
@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='arangosh/ArangoShell/ArangoClient.cpp' object='arangosh/ArangoShell/bin_arangoirb-ArangoClient.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bin_arangoirb_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o arangosh/ArangoShell/bin_arangoirb-ArangoClient.obj `if test -f 'arangosh/ArangoShell/ArangoClient.cpp'; then $(CYGPATH_W) 'arangosh/ArangoShell/ArangoClient.cpp'; else $(CYGPATH_W) '$(srcdir)/arangosh/ArangoShell/ArangoClient.cpp'; fi`
arangoirb/MRClient/bin_arangoirb-MRubyClientConnection.o: arangoirb/MRClient/MRubyClientConnection.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bin_arangoirb_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT arangoirb/MRClient/bin_arangoirb-MRubyClientConnection.o -MD -MP -MF arangoirb/MRClient/$(DEPDIR)/bin_arangoirb-MRubyClientConnection.Tpo -c -o arangoirb/MRClient/bin_arangoirb-MRubyClientConnection.o `test -f 'arangoirb/MRClient/MRubyClientConnection.cpp' || echo '$(srcdir)/'`arangoirb/MRClient/MRubyClientConnection.cpp
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) arangoirb/MRClient/$(DEPDIR)/bin_arangoirb-MRubyClientConnection.Tpo arangoirb/MRClient/$(DEPDIR)/bin_arangoirb-MRubyClientConnection.Po
@ -5251,22 +5276,10 @@ build.h: configure.ac
################################################################################
################################################################################
### @brief server config
### @brief config
################################################################################
etc/arangodb/arangod.conf: etc/arangodb/arangod.conf.in Makefile
@test -d etc/arangodb || mkdir -p etc/arangodb
sed \
-e 's%@DATABASEDIR@%${TRI_DATABASEDIR}%g' \
-e 's%@LOGDIR@%${TRI_LOGDIR}%g' \
-e 's%@PKGDATADIR@%${TRI_PKGDATADIR}%g' \
$< > $@
################################################################################
### @brief client config
################################################################################
etc/arangodb/arangosh.conf: etc/arangodb/arangosh.conf.in Makefile
etc/arangodb/%.conf: etc/arangodb/%.conf.in Makefile
@test -d etc/arangodb || mkdir -p etc/arangodb
sed \
-e 's%@DATABASEDIR@%${TRI_DATABASEDIR}%g' \

View File

@ -36,6 +36,7 @@
#include "build.h"
#include "ArangoShell/ArangoClient.h"
#include "Basics/FileUtils.h"
#include "Basics/ProgramOptions.h"
#include "Basics/ProgramOptionsDescription.h"
@ -65,46 +66,6 @@ using namespace triagens::mrclient;
#include "mr/common/bootstrap/mr-error.h"
// -----------------------------------------------------------------------------
// --SECTION-- private constants
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup V8Shell
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief connection default values
////////////////////////////////////////////////////////////////////////////////
static int64_t const DEFAULT_REQUEST_TIMEOUT = 300;
static size_t const DEFAULT_RETRIES = 2;
static int64_t const DEFAULT_CONNECTION_TIMEOUT = 3;
////////////////////////////////////////////////////////////////////////////////
/// @brief colors for output
////////////////////////////////////////////////////////////////////////////////
static char const DEF_RED[6] = "\x1b[31m";
// static char const DEF_BOLD_RED[8] = "\x1b[1;31m";
static char const DEF_GREEN[6] = "\x1b[32m";
// static char const DEF_BOLD_GREEN[8] = "\x1b[1;32m";
// static char const DEF_BLUE[6] = "\x1b[34m";
// static char const DEF_BOLD_BLUE[8] = "\x1b[1;34m";
// static char const DEF_YELLOW[8] = "\x1b[1;33m";
// static char const DEF_WHITE[6] = "\x1b[37m";
// static char const DEF_BOLD_WHITE[8] = "\x1b[1;37m";
// static char const DEF_BLACK[6] = "\x1b[30m";
// static char const DEF_BOLD_BLACK[8] = "\x1b[1;39m";
// static char const DEF_BLINK[5] = "\x1b[5m";
// static char const DEF_BRIGHT[5] = "\x1b[1m";
static char const DEF_RESET[5] = "\x1b[0m";
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- private variables
// -----------------------------------------------------------------------------
@ -115,22 +76,10 @@ static char const DEF_RESET[5] = "\x1b[0m";
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief configuration file
/// @brief base class for clients
////////////////////////////////////////////////////////////////////////////////
static string ConfigFile = "";
////////////////////////////////////////////////////////////////////////////////
/// @brief whether or not a password was specified on the command line
////////////////////////////////////////////////////////////////////////////////
static bool HasPassword = false;
////////////////////////////////////////////////////////////////////////////////
/// @brief endpoint
////////////////////////////////////////////////////////////////////////////////
static Endpoint* EndpointServer = 0;
ArangoClient BaseClient;
////////////////////////////////////////////////////////////////////////////////
/// @brief the initial default connection
@ -138,66 +87,6 @@ static Endpoint* EndpointServer = 0;
MRubyClientConnection* ClientConnection = 0;
////////////////////////////////////////////////////////////////////////////////
/// @brief connect timeout (in s)
////////////////////////////////////////////////////////////////////////////////
static int64_t ConnectTimeout = DEFAULT_CONNECTION_TIMEOUT;
////////////////////////////////////////////////////////////////////////////////
/// @brief disable auto completion
////////////////////////////////////////////////////////////////////////////////
static bool NoAutoComplete = false;
////////////////////////////////////////////////////////////////////////////////
/// @brief deactivate colors
////////////////////////////////////////////////////////////////////////////////
static bool NoColors = false;
////////////////////////////////////////////////////////////////////////////////
/// @brief the output pager
////////////////////////////////////////////////////////////////////////////////
static string OutputPager = "less -X -R -F -L";
////////////////////////////////////////////////////////////////////////////////
/// @brief use pretty print
////////////////////////////////////////////////////////////////////////////////
static bool PrettyPrint = false;
////////////////////////////////////////////////////////////////////////////////
/// @brief quiet start
////////////////////////////////////////////////////////////////////////////////
static bool Quiet = false;
////////////////////////////////////////////////////////////////////////////////
/// @brief request timeout (in s)
////////////////////////////////////////////////////////////////////////////////
static int64_t RequestTimeout = DEFAULT_REQUEST_TIMEOUT;
////////////////////////////////////////////////////////////////////////////////
/// @brief endpoint to connect to
////////////////////////////////////////////////////////////////////////////////
static string EndpointServerString;
////////////////////////////////////////////////////////////////////////////////
/// @brief user to send to endpoint
////////////////////////////////////////////////////////////////////////////////
static string Username = "root";
////////////////////////////////////////////////////////////////////////////////
/// @brief password to send to endpoint
////////////////////////////////////////////////////////////////////////////////
static string Password = "";
////////////////////////////////////////////////////////////////////////////////
/// @brief startup MR files
////////////////////////////////////////////////////////////////////////////////
@ -216,12 +105,6 @@ static string StartupModules = "";
static string StartupPath = "";
////////////////////////////////////////////////////////////////////////////////
/// @brief use pager
////////////////////////////////////////////////////////////////////////////////
static bool UsePager = false;
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
@ -287,12 +170,12 @@ static mrb_value ClientConnection_httpGet (mrb_state* mrb, mrb_value self) {
static MRubyClientConnection* createConnection (MR_state_t* mrs) {
return new MRubyClientConnection(mrs,
EndpointServer,
Username,
Password,
(double) RequestTimeout,
(double) ConnectTimeout,
DEFAULT_RETRIES,
BaseClient.endpointServer(),
BaseClient.username(),
BaseClient.password(),
BaseClient.requestTimeout(),
BaseClient.connectTimeout(),
ArangoClient::DEFAULT_RETRIES,
false);
}
@ -301,19 +184,8 @@ static MRubyClientConnection* createConnection (MR_state_t* mrs) {
////////////////////////////////////////////////////////////////////////////////
static void ParseProgramOptions (int argc, char* argv[]) {
string level = "info";
ProgramOptionsDescription description("STANDARD options");
ProgramOptionsDescription ruby("RUBY options");
ProgramOptionsDescription client("CLIENT options");
ProgramOptionsDescription logging("LOGGING options");
ProgramOptionsDescription hidden("HIDDEN options");
hidden
("auto-complete", "enable auto completion, use no-auto-complete to disable")
("colors", "activate color support")
("no-pretty-print", "disable pretty printting")
;
ruby
("ruby.directory", &StartupPath, "startup paths containing the Ruby files; multiple directories can be separated by cola")
@ -321,126 +193,20 @@ static void ParseProgramOptions (int argc, char* argv[]) {
;
description
("configuration,c", &ConfigFile, "read configuration file")
("help,h", "help message")
("no-auto-complete", "disable auto completion")
("no-colors", "deactivate color support")
("pager", &OutputPager, "output pager")
("pretty-print", "pretty print values")
("quiet,s", "no banner")
("use-pager", "use pager")
(client, false)
(javascript, false)
(logging, false)
(hidden, true)
(ruby, false)
;
// fill in used options
BaseClient.setupGeneral(description);
BaseClient.setupServer(description);
// and parse the command line and config file
ProgramOptions options;
if (! options.parse(description, argc, argv)) {
cerr << options.lastError() << "\n";
exit(EXIT_FAILURE);
}
// check for help
set<string> help = options.needHelp("help");
if (! help.empty()) {
cout << description.usage(help) << endl;
exit(EXIT_SUCCESS);
}
// set the logging
TRI_SetLogLevelLogging(level.c_str());
TRI_CreateLogAppenderFile("-");
// parse config file
string configFile = "";
#ifdef _SYSCONFDIR_
string sysDir = string(_SYSCONFDIR_);
string systemConfigFile = "arangosh.conf";
if (! sysDir.empty()) {
if (sysDir[sysDir.size() - 1] != '/') {
sysDir += "/" + systemConfigFile;
}
else {
sysDir += systemConfigFile;
}
if (FileUtils::exists(sysDir)) {
configFile = sysDir;
}
else {
LOGGER_DEBUG << "no system init file '" << sysDir << "'";
}
}
#endif
if (! ConfigFile.empty()) {
if (StringUtils::tolower(ConfigFile) == string("none")) {
LOGGER_INFO << "using no init file at all";
}
else {
configFile = ConfigFile;
}
}
if (! configFile.empty()) {
LOGGER_DEBUG << "using init file '" << configFile << "'";
if (! options.parse(description, configFile)) {
cout << "cannot parse config file '" << configFile << "': " << options.lastError() << endl;
exit(EXIT_FAILURE);
}
}
// check if have a password
HasPassword = options.has("server.password");
// set colors
if (options.has("colors")) {
NoColors = false;
}
if (options.has("no-colors")) {
NoColors = true;
}
// set auto-completion
if (options.has("auto-complete")) {
NoAutoComplete = false;
}
if (options.has("no-auto-complete")) {
NoAutoComplete = true;
}
// set pretty print
if (options.has("pretty-print")) {
PrettyPrint = true;
}
if (options.has("no-pretty-print")) {
PrettyPrint = false;
}
// set pager
if (options.has("use-pager")) {
UsePager = true;
}
// set quiet
if (options.has("quiet")) {
Quiet = true;
}
BaseClient.parse(options, description, argc, argv, "arangoirb.conf");
// check module path
if (StartupModules.empty()) {
LOGGER_FATAL << "module path not known, please use '--javascript.modules-path'";
LOGGER_FATAL << "module path not known, please use '--ruby.modules-path'";
exit(EXIT_FAILURE);
}
}
@ -528,9 +294,8 @@ static void RunShell (MR_state_t* mrs) {
console->close();
cout << endl;
if (! Quiet) {
cout << endl << "Bye Bye! Auf Wiedersehen! さようなら" << endl;
}
BaseClient.printByeBye();
}
////////////////////////////////////////////////////////////////////////////////
@ -557,7 +322,7 @@ int main (int argc, char* argv[]) {
TRI_InitialiseLogging(false);
int ret = EXIT_SUCCESS;
EndpointServerString = Endpoint::getDefaultEndpoint();
BaseClient.setEndpointString(Endpoint::getDefaultEndpoint());
// .............................................................................
// parse the program options
@ -565,37 +330,6 @@ int main (int argc, char* argv[]) {
ParseProgramOptions(argc, argv);
// check connection args
if (ConnectTimeout <= 0) {
cerr << "invalid value for --server.connect-timeout" << endl;
exit(EXIT_FAILURE);
}
if (RequestTimeout <= 0) {
cerr << "invalid value for --server.request-timeout" << endl;
exit(EXIT_FAILURE);
}
if (Username.size() == 0) {
// must specify a user name
cerr << "no value specified for --server.username" << endl;
exit(EXIT_FAILURE);
}
if (! HasPassword) {
// no password given on command-line
cout << "Please specify a password:" << endl;
// now prompt for it
#ifdef TRI_HAVE_TERMIOS_H
TRI_SetStdinVisibility(false);
getline(cin, Password);
TRI_SetStdinVisibility(true);
#else
getline(cin, Password);
#endif
}
// .............................................................................
// set-up MRuby objects
// .............................................................................
@ -605,24 +339,21 @@ int main (int argc, char* argv[]) {
TRI_InitMRUtils(mrs);
// .............................................................................
// set-up client connection
// .............................................................................
// check if we want to connect to a server
bool useServer = (EndpointServerString != "none");
bool useServer = (BaseClient.endpointString() != "none");
if (useServer) {
EndpointServer = Endpoint::clientFactory(EndpointServerString);
BaseClient.createEndpoint();
if (EndpointServer == 0) {
cerr << "invalid value for --server.endpoint ('" << EndpointServerString.c_str() << "')" << endl;
if (BaseClient.endpointServer() == 0) {
cerr << "invalid value for --server.endpoint ('" << BaseClient.endpointString() << "')" << endl;
exit(EXIT_FAILURE);
}
assert(EndpointServer);
ClientConnection = createConnection(mrs);
InitMRClientConnection(&mrs->_mrb, ClientConnection);
}
@ -632,12 +363,12 @@ int main (int argc, char* argv[]) {
// .............................................................................
// http://www.network-science.de/ascii/ Font: ogre
if (! Quiet) {
char const* g = DEF_GREEN;
char const* r = DEF_RED;
char const* z = DEF_RESET;
if (! BaseClient.quiet()) {
char const* g = ArangoClient::COLOR_GREEN;
char const* r = ArangoClient::COLOR_RED;
char const* z = ArangoClient::COLOR_RESET;
if (NoColors) {
if (! BaseClient.colors()) {
g = "";
r = "";
z = "";
@ -662,22 +393,17 @@ int main (int argc, char* argv[]) {
cout << endl;
if (UsePager) {
cout << "Using pager '" << OutputPager << "' for output buffering." << endl;
}
if (PrettyPrint) {
cout << "Pretty print values." << endl;
}
BaseClient.printWelcomeInfo();
if (useServer) {
if (ClientConnection->isConnected()) {
if (! Quiet) {
cout << "Connected to ArangoDB '" << EndpointServer->getSpecification() << "' Version " << ClientConnection->getVersion() << endl;
if (! BaseClient.quiet()) {
cout << "Connected to ArangoDB '" << BaseClient.endpointServer()->getSpecification()
<< "' Version " << ClientConnection->getVersion() << endl;
}
}
else {
cerr << "Could not connect to endpoint '" << EndpointServerString << "'" << endl;
cerr << "Could not connect to endpoint '" << BaseClient.endpointString() << "'" << endl;
cerr << "Error message '" << ClientConnection->getErrorMessage() << "'" << endl;
}
}

View File

@ -10,6 +10,7 @@
bin_arangoirb_CPPFLAGS = \
-I@top_srcdir@/arangoirb \
-I@top_srcdir@/arangosh \
$(AM_CPPFLAGS)
bin_arangoirb_LDADD = \
@ -20,6 +21,7 @@ bin_arangoirb_LDADD = \
@MRUBY_LIBS@
bin_arangoirb_SOURCES = \
arangosh/ArangoShell/ArangoClient.cpp \
arangoirb/MRClient/MRubyClientConnection.cpp \
arangoirb/MRClient/arangoirb.cpp

View File

@ -314,7 +314,11 @@ void ArangoClient::setupServer (ProgramOptionsDescription& description) {
/// @brief parses command line and config file and prepares logging
////////////////////////////////////////////////////////////////////////////////
void ArangoClient::parse (ProgramOptions& options, ProgramOptionsDescription& description, int argc, char* argv[]) {
void ArangoClient::parse (ProgramOptions& options,
ProgramOptionsDescription& description,
int argc,
char* argv[],
string const& initFilename) {
if (! options.parse(description, argc, argv)) {
cerr << options.lastError() << "\n";
exit(EXIT_FAILURE);
@ -349,7 +353,7 @@ void ArangoClient::parse (ProgramOptions& options, ProgramOptionsDescription& de
else {
string sysDir = string(_SYSCONFDIR_);
string systemConfigFile = "arangosh.conf";
string systemConfigFile = initFilename;
if (! sysDir.empty()) {
if (sysDir[sysDir.size() - 1] != '/') {

View File

@ -268,7 +268,8 @@ namespace triagens {
void parse (triagens::basics::ProgramOptions&,
triagens::basics::ProgramOptionsDescription& description,
int argc,
char* argv[]);
char* argv[],
string const& initFilename);
////////////////////////////////////////////////////////////////////////////////
/// @brief starts pager

View File

@ -162,7 +162,7 @@ static void ParseProgramOptions (int argc, char* argv[]) {
description.arguments(&arguments);
ProgramOptions options;
BaseClient.parse(options, description, argc, argv);
BaseClient.parse(options, description, argc, argv, "arangoimp.conf");
if (FileName == "" && arguments.size() > 0) {
FileName = arguments[0];

View File

@ -399,7 +399,7 @@ static void ParseProgramOptions (int argc, char* argv[]) {
// and parse the command line and config file
ProgramOptions options;
BaseClient.parse(options, description, argc, argv);
BaseClient.parse(options, description, argc, argv, "arangosh.conf");
// set V8 options
v8::V8::SetFlagsFromCommandLine(&argc, argv, true);

View File

@ -6,25 +6,14 @@
BUILT_SOURCES += \
etc/arangodb/arangod.conf \
etc/arangodb/arangoirb.conf \
etc/arangodb/arangosh.conf
################################################################################
### @brief server config
### @brief config
################################################################################
etc/arangodb/arangod.conf: etc/arangodb/arangod.conf.in Makefile
@test -d etc/arangodb || mkdir -p etc/arangodb
sed \
-e 's%@DATABASEDIR@%${TRI_DATABASEDIR}%g' \
-e 's%@LOGDIR@%${TRI_LOGDIR}%g' \
-e 's%@PKGDATADIR@%${TRI_PKGDATADIR}%g' \
$< > $@
################################################################################
### @brief client config
################################################################################
etc/arangodb/arangosh.conf: etc/arangodb/arangosh.conf.in Makefile
etc/arangodb/%.conf: etc/arangodb/%.conf.in Makefile
@test -d etc/arangodb || mkdir -p etc/arangodb
sed \
-e 's%@DATABASEDIR@%${TRI_DATABASEDIR}%g' \

View File

@ -0,0 +1,5 @@
[server]
endpoint = tcp://localhost:8529
[ruby]
modules-path = @PKGDATADIR@/mr/client/modules;@PKGDATADIR@/mr/common/modules

View File

@ -0,0 +1,2 @@
[ruby]
modules-path = ./mr/client/modules;./mr/common/modules