Skip to content

Commit b3667a3

Browse files
Copiloteleanorjboyd
andcommitted
Implement PET command submenu with find and resolve options
Co-authored-by: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com>
1 parent 94e5415 commit b3667a3

2 files changed

Lines changed: 50 additions & 3 deletions

File tree

package.nls.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,5 @@
3636
"python-envs.terminal.deactivate.title": "Deactivate Environment in Current Terminal",
3737
"python-envs.uninstallPackage.title": "Uninstall Package",
3838
"python-envs.revealProjectInExplorer.title": "Reveal Project in Explorer",
39-
"python-envs.runPetInTerminal.title": "Run Python Environment Tool (PET) in Terminal"
39+
"python-envs.runPetInTerminal.title": "Run Python Environment Tool (PET) in Terminal..."
4040
}

src/extension.ts

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,12 +450,59 @@ export async function activate(context: ExtensionContext): Promise<PythonEnviron
450450
commands.registerCommand('python-envs.runPetInTerminal', async () => {
451451
try {
452452
const petPath = await getNativePythonToolsPath();
453+
454+
// Show quick pick menu for PET operation selection
455+
const selectedOption = await window.showQuickPick([
456+
{
457+
label: 'Find All Environments',
458+
description: 'Finds all environments and reports them to the standard output',
459+
detail: 'Runs: pet find --verbose'
460+
},
461+
{
462+
label: 'Resolve Environment...',
463+
description: 'Resolves & reports the details of the environment to the standard output',
464+
detail: 'Runs: pet resolve <path>'
465+
}
466+
], {
467+
placeHolder: 'Select a Python Environment Tool (PET) operation',
468+
ignoreFocusOut: true
469+
});
470+
471+
if (!selectedOption) {
472+
return; // User cancelled
473+
}
474+
453475
const terminal = createTerminal({
454476
name: 'Python Environment Tool (PET)',
455477
});
456478
terminal.show();
457-
terminal.sendText(`"${petPath}"`, true);
458-
traceInfo(`Running PET in terminal: ${petPath}`);
479+
480+
if (selectedOption.label === 'Find All Environments') {
481+
// Run pet find --verbose
482+
terminal.sendText(`"${petPath}" find --verbose`, true);
483+
traceInfo(`Running PET find command: ${petPath} find --verbose`);
484+
} else if (selectedOption.label === 'Resolve Environment...') {
485+
// Show input box for path
486+
const inputPath = await window.showInputBox({
487+
prompt: 'Enter the path to the Python executable to resolve',
488+
placeHolder: '/path/to/python/executable',
489+
ignoreFocusOut: true,
490+
validateInput: (value) => {
491+
if (!value || value.trim().length === 0) {
492+
return 'Please enter a valid path';
493+
}
494+
return null;
495+
}
496+
});
497+
498+
if (!inputPath) {
499+
return; // User cancelled
500+
}
501+
502+
// Run pet resolve with the provided path
503+
terminal.sendText(`"${petPath}" resolve "${inputPath.trim()}"`, true);
504+
traceInfo(`Running PET resolve command: ${petPath} resolve "${inputPath.trim()}"`);
505+
}
459506
} catch (error) {
460507
traceError('Error running PET in terminal', error);
461508
window.showErrorMessage(`Failed to run Python Environment Tool: ${error}`);

0 commit comments

Comments
 (0)