Open vikramsubramanian opened 4 months ago
Summary: Add a new "print_configs" command to the CLI to display the current shell configuration parameters.
To implement the feature described in the Jira ticket (hashtag2805), you will need to add a new command to the CLI of the Kùzu embedded graph database that prints the current shell configuration. Here's how you can implement this feature:
Add a new command to the ShellCommand
struct in embedded_shell.cpp
:
const char* PRINT_CONFIGS = ":print_configs";
Add the new command to the commandList
array within the ShellCommand
struct:
const std::array<const char*, 7> commandList = {
HELP, CLEAR, QUIT, THREAD, LOGGING_LEVEL, QUERY_TIMEOUT, PRINT_CONFIGS};
Implement a new method in the EmbeddedShell
class to print the configurations:
void EmbeddedShell::printConfigs() {
printf("Current shell configuration:\n");
printf("%sNumber of threads: %d\n", TAB, conn->getMaxNumThreadForExec());
printf("%sQuery timeout: %llu ms\n", TAB, conn->getQueryTimeOut());
printf("%sLogging level: %s\n", TAB, database->getLoggingLevel().c_str());
}
In the EmbeddedShell::run()
method, add a new condition to handle the PRINT_CONFIGS
command:
else if (lineStr == shellCommand.PRINT_CONFIGS) {
printConfigs();
}
Update the EmbeddedShell::printHelp()
method to include help information for the new command:
printf("%s%s %sprint current shell configuration\n", TAB, shellCommand.PRINT_CONFIGS, TAB);
Make sure to test the new command after implementing it to ensure it works as expected and that it correctly prints the current configuration of the shell, including the number of threads, query timeout, and logging level.
tools/shell/embedded_shell.cpp
This file contains the shell command definitions and the logic for handling user input, which is where the new 'print_configs' command should be integrated.
tools/shell/embedded_shell.cpp
This snippet includes the 'printHelp' function, which will need to be updated to include help information for the new 'print_configs' command.
tools/shell/embedded_shell.cpp
This snippet contains the 'run' method where the logic for executing shell commands is implemented. The new 'print_configs' command will need to be handled here.
I am often in a state where I want to see the state of my configuration for shell after I run a query. That is I want to know what are the current numThreads or timeout. We should have a command (something like "print_configs" that will print out any of the configurable parameters from the shell. Currently these include: :thread, :timeout, and logging_level. )