From b4186eaa111b75a77347894d221888af01956d82 Mon Sep 17 00:00:00 2001 From: Dervex Date: Sun, 7 Apr 2024 23:31:47 +0200 Subject: [PATCH] Implement `debug` command --- .eslintrc.json | 3 ++- src/argon.ts | 7 +++--- src/commands/openMenu.ts | 5 ++--- src/menu/debug.ts | 46 +++++++++++++++++++++++++++++++++++++++- src/menu/index.ts | 8 +++---- tsconfig.json | 4 ++-- 6 files changed, 58 insertions(+), 15 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 1a3f1b8..3dc9e0d 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -12,7 +12,8 @@ "curly": "warn", "eqeqeq": "warn", "no-throw-literal": "warn", - "semi": "off" + "semi": "off", + "no-unused-vars": "warn" }, "ignorePatterns": ["out", "dist", "**/*.d.ts"] } diff --git a/src/argon.ts b/src/argon.ts index c457097..2a36f23 100644 --- a/src/argon.ts +++ b/src/argon.ts @@ -1,4 +1,3 @@ -import * as vscode from 'vscode' import * as childProcess from 'child_process' import * as logger from './logger' import * as util from './util' @@ -77,9 +76,9 @@ export function exec(code: string) { run(`exec "${code}"`) } -// export function debug(mode: string) { -// run(`debug "${mode}"`) -// } +export function debug(mode: string) { + run(`debug ${mode}`) +} export function studio() { run('studio') diff --git a/src/commands/openMenu.ts b/src/commands/openMenu.ts index 10ea934..ab37a99 100644 --- a/src/commands/openMenu.ts +++ b/src/commands/openMenu.ts @@ -5,9 +5,8 @@ import { State } from '../state' export function openMenu(state: State) { return vscode.commands.registerCommand('argon.openMenu', () => { - const items = menu.items() - const quickPick = vscode.window - .showQuickPick(items, { + vscode.window + .showQuickPick(menu.items(), { title: 'Argon', }) .then(async (item) => { diff --git a/src/menu/debug.ts b/src/menu/debug.ts index e68db2f..ee8850e 100644 --- a/src/menu/debug.ts +++ b/src/menu/debug.ts @@ -1,4 +1,5 @@ import * as vscode from 'vscode' +import * as argon from '../argon' import { Item } from '.' export const item: Item = { @@ -7,4 +8,47 @@ export const item: Item = { action: 'debug', } -export function handler() {} +function getMode(): Promise { + return new Promise((resolve, reject) => { + const items = [ + { + label: '$(vm) Play', + description: 'F5', + action: 'play', + }, + { + label: '$(server-environment) Run', + description: 'F8', + action: 'run', + }, + { + label: '$(server) Start', + description: 'F7', + action: 'start', + }, + { + label: '$(stop-circle) Stop', + description: 'Shift + F5', + action: 'stop', + }, + ] + + vscode.window + .showQuickPick(items, { + title: 'Select playtest mode', + }) + .then((mode) => { + if (!mode) { + return reject() + } + + resolve(mode.action) + }) + }) +} + +export async function handler() { + const mode = await getMode() + + argon.debug(mode) +} diff --git a/src/menu/index.ts b/src/menu/index.ts index 5c694b3..3c9fa9e 100644 --- a/src/menu/index.ts +++ b/src/menu/index.ts @@ -63,8 +63,8 @@ export function items(): (Item | Divider)[] { init.item, stop.item, helpers(), - exec.item, debug.item, + exec.item, studio.item, plugin.item, misc(), @@ -95,12 +95,12 @@ export async function onDidAccept(action: string, state: State) { await stop.handler(state) break + case 'debug': + await debug.handler() + break case 'exec': exec.handler() break - case 'debug': - debug.handler() - break case 'studio': studio.handler() break diff --git a/tsconfig.json b/tsconfig.json index 6f74fb4..c46e0b3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,11 +5,11 @@ "outDir": "out", "lib": ["ES2020"], "sourceMap": true, - "strict": true + "strict": true, + "noUnusedParameters": true /* Additional Checks */ // "rootDir": "src", // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ - // "noUnusedParameters": true, /* Report errors on unused parameters. */ } }