Commit b79e9216 authored by Ivan Mazhukin's avatar Ivan Mazhukin

prefill app from active eepm script

parent 2cf551f6
......@@ -43,7 +43,7 @@ The same VSIX can be installed from the VS Code command `Extensions: Install fro
- `Rerun last command`: repeats the last generated command.
- `Open log folder`: opens `${XDG_STATE_HOME:-$HOME/.local/state}/epm-docker-test` or the configured log root.
For local `epm play` commands, the app name is inferred from the active editor when the file is in `play.d`, `pack.d`, or `repack.d`. The extension first checks simple shell variables such as `PRODUCT=rstudio` or `PKGNAME=rstudio`, then falls back to the file name without extension. Before running, it asks for confirmation with the inferred app, source file, and exact command.
When an app name is requested, it is inferred from the active editor if the file is in `play.d`, `pack.d`, or `repack.d`. The extension first checks simple shell variables such as `PRODUCT=rstudio` or `PKGNAME=rstudio`, then falls back to the file name without extension. The inferred app is prefilled in the app input field and can be edited before running.
## Favorites
......
......@@ -129,11 +129,10 @@ async function runQuick() {
}
async function runApp() {
const app = await vscode.window.showInputBox({
const app = await promptForApp({
title: 'EPM Docker Test',
prompt: 'Application name for epm play',
placeHolder: 'telegram',
value: getWorkspaceState('lastApp', '')
fallbackKey: 'lastApp'
});
if (!app) {
return;
......@@ -154,11 +153,10 @@ async function runApp() {
}
async function runPreset() {
const app = await vscode.window.showInputBox({
const app = await promptForApp({
title: 'EPM Docker Test',
prompt: 'Application name for epm play',
placeHolder: 'telegram',
value: getWorkspaceState('lastApp', '')
fallbackKey: 'lastApp'
});
if (!app) {
return;
......@@ -226,14 +224,11 @@ async function runLocalPlay(latest) {
}
const inferred = inferAppFromActiveEditor(eepmRoot);
const fallback = getWorkspaceState('lastLocalApp', getWorkspaceState('lastApp', ''));
const app = await vscode.window.showInputBox({
const app = await promptForApp({
title: latest ? 'Local epm play --latest' : 'Local epm play',
prompt: inferred
? `Application name inferred from ${inferred.source}`
: 'Application name for local ./bin/epm play',
value: inferred?.app || fallback,
placeHolder: 'rstudio'
prompt: 'Application name for local ./bin/epm play',
fallbackKey: 'lastLocalApp',
inferred
});
if (!app) {
......@@ -254,25 +249,23 @@ async function runLocalPlay(latest) {
...args.map(shellQuote)
].join(' ');
const confirmed = await confirmLocalPlay(app, inferred, command);
if (!confirmed) {
return;
}
await setWorkspaceState('lastLocalApp', app);
lastRun = command;
await setWorkspaceState('lastCommand', command);
sendToTerminal(command);
}
async function confirmLocalPlay(app, inferred, command) {
const sourceText = inferred ? `\nSource: ${inferred.source}` : '';
const answer = await vscode.window.showWarningMessage(
`Собираемся проверить приложение: ${app}${sourceText}\n\n${command}\n\nСогласны?`,
{ modal: true },
'Запустить'
);
return answer === 'Запустить';
async function promptForApp(options) {
const inferred = options.inferred || inferAppFromActiveEditor(resolveWorkspacePath(getConfig().get('localEpmRoot', '/home/vano/eter/static2/eepm')));
const fallback = getWorkspaceState(options.fallbackKey, getWorkspaceState('lastApp', ''));
return vscode.window.showInputBox({
title: options.title,
prompt: inferred
? `${options.prompt} (inferred from ${inferred.source})`
: options.prompt,
value: inferred?.app || fallback,
placeHolder: 'rstudio'
});
}
async function rerunLast() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment