11 #include "eckit/io/FileHandle.h"
13 #include "eckit/sql/expression/function/FunctionFactory.h"
24 using namespace eckit;
29 int gdb(
int argc,
char *argv[]);
30 int valgrind(
int argc,
char *argv[]);
31 int sqlhelp(
int argc,
char *argv[]);
33 int main(
int argc,
char *argv[])
36 }
catch (std::exception& e) {
37 cerr << argv[0] <<
": " << e.what() << std::endl;
40 cerr << argv[0] <<
": unknown exception" << std::endl;
51 cerr <<
"Usage:" << endl
52 <<
" " << argv[0] <<
" <command> [<command's-parameters>]" << endl
53 <<
" " << argv[0] <<
" help <command>" << std::endl << endl
54 <<
"Available commands:" << std::endl;
56 AbstractToolFactory::listTools(cout);
60 const string firstArg(argv[1]);
67 if (firstArg ==
"test")
71 std::cout <<
"Testing C API" << std::endl;
73 string testCapi = std::string(argv[0]) +
" testodbcapi";
74 cerr <<
"Executing '" << testCapi <<
"'" << std::endl;
75 int rc = system(testCapi.c_str());
79 std::cout << std::endl <<
"Running tests." << std::endl;
87 if (firstArg ==
"help")
91 AbstractToolFactory::printToolsHelp(cout);
94 AbstractToolFactory::printToolHelp(argv[2], cout);
95 std::cout << std::endl <<
"Usage:" << std::endl << std::endl <<
"\t";
96 AbstractToolFactory::printToolUsage(argv[2], cout);
101 if (firstArg ==
"sqlhelp")
return sqlhelp(argc, argv);
103 if (firstArg ==
"-V" || firstArg ==
"-v" || firstArg ==
"--version")
111 return runner.start();
114 int gdb(
int argc,
char *argv[])
116 string cmd = argv[0];
118 string gdbScript = argv[1];
119 for (
int i = 2;
i < argc;
i++)
120 args += std::string(
" ") + argv[
i];
122 PathName scriptFile (std::string(
".gdb_") + std::string(argc < 3 ?
"odc" : argv[2]));
124 if (! scriptFile.exists())
126 string s = std::string(
"file ") + cmd +
"\nbreak main\nrun " +
args +
"\ncatch throw\n";
127 FileHandle
f(scriptFile);
128 f.openForWrite(1024);
129 f.write(s.c_str(), s.size());
132 string vi = std::string(
"vi ") + scriptFile;
133 string gdb = std::string(
"gdb -x ") + scriptFile;
134 std::cout <<
"Executing '" << vi <<
"'" << std::endl;
136 std::cout <<
"Executing '" <<
gdb <<
"'" << std::endl;
137 return system(
gdb.c_str());
143 string cmd = argv[0];
145 for (
int i = 2;
i < argc;
i++)
146 args += std::string(
" ") + argv[
i];
149 string logFile = std::string(
"vg.") + argv[2] +
".log";
150 string vg = std::string(
"valgrind --log-file=") + logFile +
" --show-reachable=yes --leak-check=full "
151 +
" --db-attach=yes "
153 std::cout <<
"Executing '" << vg <<
"'" << std::endl;
154 return system(vg.c_str());
159 auto info = eckit::sql::expression::function::FunctionFactory::instance().functionsInfo();
161 for (
auto&
i : info) {
162 std::cout <<
i.name <<
"/" <<
i.arity <<
" " <<
i.help << std::endl;
static unsigned int formatVersionMinor()
static const char * version()
static unsigned int formatVersionMajor()
void odb_start_with_args(int argc, char *argv[])