Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ai.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ async function main(continuePrompt = true) {
}
}

if (import.meta.url === `file://${process.argv[1]}`) {

if (!`file://${process.argv[1]}`.includes('!')) {
main();
}

Expand Down
9 changes: 4 additions & 5 deletions aic.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ async function chatPrompt() {
}

async function startConversation(client, initialQuestion) {
const exitWords = new Set(["exit", "goodbye", "quit"]);

let continueConversation = true;
let question = initialQuestion;

Expand All @@ -61,7 +59,7 @@ async function startConversation(client, initialQuestion) {
question = await chatPrompt();
}

if (shouldExitConversation(question, exitWords)) {
if (shouldExitConversation(question)) {
continueConversation = false;
break;
}
Expand All @@ -74,7 +72,8 @@ async function startConversation(client, initialQuestion) {
process.exit(0);
}

function shouldExitConversation(question, exitWords) {
function shouldExitConversation(question) {
const exitWords = new Set(["exit", "goodbye", "quit"]);
return !question || exitWords.has(question.toLowerCase().trim());
}

Expand All @@ -95,7 +94,7 @@ async function main(startConvo = true) {
}
}

if (import.meta.url === `file://${process.argv[1]}`) {
if (!`file://${process.argv[1]}`.includes('!')) {
main();
}

Expand Down
15 changes: 11 additions & 4 deletions aiq.js
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,11 @@ async function promptConnectionDetails(existingConfig = {}) {
};
}

function shouldExitConversation(question) {
const exitWords = new Set(["exit", "goodbye", "quit"]);
return !question || exitWords.has(question.toLowerCase().trim());
}

async function promptForCommands(dbConfigs, connectionNameOrFile, client) {
let command;
do {
Expand All @@ -441,10 +446,12 @@ async function promptForCommands(dbConfigs, connectionNameOrFile, client) {
]);
command = input.command;

if (command.toLowerCase() !== "exit") {
await processQuery(dbConfigs, connectionNameOrFile, command, client);
if (shouldExitConversation(command)) {
break;
}
} while (command.toLowerCase() !== "exit");

await processQuery(dbConfigs, connectionNameOrFile, command, client);
} while (true);
}

async function handleNoOrSingleParam() {
Expand Down Expand Up @@ -487,7 +494,7 @@ async function main(prompt = true) {
process.exit(0);
}

if (import.meta.url === `file://${process.argv[1]}`) {
if (!`file://${process.argv[1]}`.includes('!')) {
main();
}

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "command-ai",
"version": "0.20.0",
"version": "0.21.0",
"description": "Command AI",
"main": "ai.js",
"type": "module",
Expand Down