MCPcopy Create free account
hub / github.com/LadybugDB/ladybug / processRunCommands

Function processRunCommands

tools/shell/shell_runner.cpp:54–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52}
53
54void processRunCommands(EmbeddedShell& shell, const std::shared_ptr<Connection>& conn,
55 const std::string& filename) {
56 std::string fileContents;
57 try {
58 auto context = conn->getClientContext();
59 auto fileInfo = VirtualFileSystem::GetUnsafe(*context)->openFile(filename,
60 FileOpenFlags(FileFlags::READ_ONLY), context);
61 auto fileSize = fileInfo->getFileSize();
62 fileContents.resize(fileSize);
63 if (fileSize > 0) {
64 fileInfo->readFromFile(fileContents.data(), fileSize, 0);
65 }
66 } catch (Exception& e) {
67 if (filename != ".lbugrc") {
68 std::cerr << "Warning: cannot open init file: " << filename << ": " << e.what() << '\n';
69 }
70 return;
71 }
72
73 std::cout << "-- Processing: " << filename << '\n';
74 std::istringstream stream{fileContents};
75 std::string line;
76 while (std::getline(stream, line)) {
77 line += '\n';
78 auto queryResults = shell.processInput(line);
79 for (auto& queryResult : queryResults) {
80 if (!queryResult->isSuccess()) {
81 shell.printErrorMessage(line, *queryResult);
82 }
83 }
84 }
85}
86
87bool isHttpfsLoaded(const std::shared_ptr<Connection>& conn) {
88 const auto& loadedExtensions =

Callers 1

mainFunction · 0.85

Calls 11

FileOpenFlagsClass · 0.85
whatMethod · 0.80
processInputMethod · 0.80
printErrorMessageMethod · 0.80
getClientContextMethod · 0.45
openFileMethod · 0.45
getFileSizeMethod · 0.45
resizeMethod · 0.45
readFromFileMethod · 0.45
dataMethod · 0.45
isSuccessMethod · 0.45

Tested by

no test coverage detected