From 66da2dfc8009b86437f2d80ce941158022c38482 Mon Sep 17 00:00:00 2001 From: kagami Date: Tue, 16 Apr 2024 22:06:40 +0800 Subject: [PATCH] Add an entrypoint for workflow cli for dev --- package.json | 5 +++++ src/contributes/commands.ts | 15 +++++++++++++++ src/extension.ts | 3 +++ src/toolwrapper/devchat.ts | 20 ++++++++++++++++++++ 4 files changed, 43 insertions(+) diff --git a/package.json b/package.json index b93f984..c68b4c9 100644 --- a/package.json +++ b/package.json @@ -686,6 +686,11 @@ "title": "Install slash commands", "category": "DevChat" }, + { + "command": "DevChat.TryWF", + "title": "Run workflow cli", + "category": "DevChat" + }, { "command": "DevChat.UpdataChatModels", "title": "Update Chat Models", diff --git a/src/contributes/commands.ts b/src/contributes/commands.ts index 22278cd..177b649 100644 --- a/src/contributes/commands.ts +++ b/src/contributes/commands.ts @@ -223,6 +223,21 @@ export function registerInstallCommandsCommand( context.subscriptions.push(disposable); } +export function registerTryWF( + context: vscode.ExtensionContext +) { + let disposable = vscode.commands.registerCommand( + "DevChat.TryWF", + async () => { + + const devchat = new DevChat(); + + await devchat.tryWF(); + } + ); + + context.subscriptions.push(disposable); +} export function registerDevChatChatCommand(context: vscode.ExtensionContext) { let disposable = vscode.commands.registerCommand( diff --git a/src/extension.ts b/src/extension.ts index 1b5cb6e..c65c161 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -16,6 +16,8 @@ import { registerFixCommand, registerExplainCommand, registerQuickFixCommand, + + registerTryWF, } from './contributes/commands'; import { regLanguageContext } from './contributes/context'; import { regDevChatView } from './contributes/views'; @@ -150,6 +152,7 @@ async function activate(context: vscode.ExtensionContext) { registerInstallCommandsCommand(context); + registerTryWF(context); createStatusBarItem(context); regApplyDiffResultCommand(context); diff --git a/src/toolwrapper/devchat.ts b/src/toolwrapper/devchat.ts index 1ad0e1c..262a303 100644 --- a/src/toolwrapper/devchat.ts +++ b/src/toolwrapper/devchat.ts @@ -516,6 +516,26 @@ class DevChat { return ""; } } + async tryWF(): Promise { + try { + const args = ["-m", "devchat", "workflow", "env", "remove", "--all"]; + // const args = ["-m", "mamba", "--version"]; + + const {code, stdout, stderr} = await this.runCommand(args); + + assertValue(code !== 0, stderr || `Command exited with ${code}`); + if (stderr.trim() !== "") { + logger.channel()?.warn(`${stderr}`); + } + + logger.channel()?.info(`${stdout}`); + return stdout; + } catch (error: any) { + logger.channel()?.error(`Error: ${error.message}`); + logger.channel()?.show(); + return ""; + } + } async topics(): Promise { try {