Skip to content

Commit

Permalink
Merge pull request #6 from DrNightmare/feature/get-api-key
Browse files Browse the repository at this point in the history
Take OpenAI API key as input before registering commands.
  • Loading branch information
DrNightmare authored Mar 15, 2023
2 parents cac9f27 + 3037379 commit cd47cee
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
import { Vortex } from "./vortex";

const vortexConfig = vscode.workspace.getConfiguration("vortex");
const vortex = new Vortex("openai-api-key");
let vortex: Vortex;

const displayOutput = async (
output: string,
Expand Down Expand Up @@ -38,6 +38,21 @@ const displayOutput = async (
};

export async function activate(context: vscode.ExtensionContext) {
const openAIApiKey = await vscode.window.showInputBox({
title: "OpenAI API Key",
prompt: "Enter your OpenAI API Key here",
password: true,
ignoreFocusOut: true,
});

if (!openAIApiKey) {
vscode.window.showWarningMessage(
"OpenAI API Key not provided, Vortex is not activated"
);
return;
}
vortex = new Vortex(openAIApiKey);

let disposable = vscode.commands.registerCommand(
"vortex.editCode",
async () => {
Expand Down

0 comments on commit cd47cee

Please sign in to comment.