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 ...@@ -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. - `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. - `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 ## Favorites
......
...@@ -129,11 +129,10 @@ async function runQuick() { ...@@ -129,11 +129,10 @@ async function runQuick() {
} }
async function runApp() { async function runApp() {
const app = await vscode.window.showInputBox({ const app = await promptForApp({
title: 'EPM Docker Test', title: 'EPM Docker Test',
prompt: 'Application name for epm play', prompt: 'Application name for epm play',
placeHolder: 'telegram', fallbackKey: 'lastApp'
value: getWorkspaceState('lastApp', '')
}); });
if (!app) { if (!app) {
return; return;
...@@ -154,11 +153,10 @@ async function runApp() { ...@@ -154,11 +153,10 @@ async function runApp() {
} }
async function runPreset() { async function runPreset() {
const app = await vscode.window.showInputBox({ const app = await promptForApp({
title: 'EPM Docker Test', title: 'EPM Docker Test',
prompt: 'Application name for epm play', prompt: 'Application name for epm play',
placeHolder: 'telegram', fallbackKey: 'lastApp'
value: getWorkspaceState('lastApp', '')
}); });
if (!app) { if (!app) {
return; return;
...@@ -226,14 +224,11 @@ async function runLocalPlay(latest) { ...@@ -226,14 +224,11 @@ async function runLocalPlay(latest) {
} }
const inferred = inferAppFromActiveEditor(eepmRoot); const inferred = inferAppFromActiveEditor(eepmRoot);
const fallback = getWorkspaceState('lastLocalApp', getWorkspaceState('lastApp', '')); const app = await promptForApp({
const app = await vscode.window.showInputBox({
title: latest ? 'Local epm play --latest' : 'Local epm play', title: latest ? 'Local epm play --latest' : 'Local epm play',
prompt: inferred prompt: 'Application name for local ./bin/epm play',
? `Application name inferred from ${inferred.source}` fallbackKey: 'lastLocalApp',
: 'Application name for local ./bin/epm play', inferred
value: inferred?.app || fallback,
placeHolder: 'rstudio'
}); });
if (!app) { if (!app) {
...@@ -254,25 +249,23 @@ async function runLocalPlay(latest) { ...@@ -254,25 +249,23 @@ async function runLocalPlay(latest) {
...args.map(shellQuote) ...args.map(shellQuote)
].join(' '); ].join(' ');
const confirmed = await confirmLocalPlay(app, inferred, command);
if (!confirmed) {
return;
}
await setWorkspaceState('lastLocalApp', app); await setWorkspaceState('lastLocalApp', app);
lastRun = command; lastRun = command;
await setWorkspaceState('lastCommand', command); await setWorkspaceState('lastCommand', command);
sendToTerminal(command); sendToTerminal(command);
} }
async function confirmLocalPlay(app, inferred, command) { async function promptForApp(options) {
const sourceText = inferred ? `\nSource: ${inferred.source}` : ''; const inferred = options.inferred || inferAppFromActiveEditor(resolveWorkspacePath(getConfig().get('localEpmRoot', '/home/vano/eter/static2/eepm')));
const answer = await vscode.window.showWarningMessage( const fallback = getWorkspaceState(options.fallbackKey, getWorkspaceState('lastApp', ''));
`Собираемся проверить приложение: ${app}${sourceText}\n\n${command}\n\nСогласны?`, return vscode.window.showInputBox({
{ modal: true }, title: options.title,
'Запустить' prompt: inferred
); ? `${options.prompt} (inferred from ${inferred.source})`
return answer === 'Запустить'; : options.prompt,
value: inferred?.app || fallback,
placeHolder: 'rstudio'
});
} }
async function rerunLast() { 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