Skip to content

Commit 66674cf

Browse files
committed
add command to add Python project given resource
1 parent 07a8cf4 commit 66674cf

3 files changed

Lines changed: 20 additions & 6 deletions

File tree

package.json

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@
124124
"category": "Python",
125125
"icon": "$(new-folder)"
126126
},
127+
{
128+
"command": "python-envs.addPythonProjectGivenResource",
129+
"title": "%python-envs.addPythonProjectGivenResource.title%",
130+
"category": "Python",
131+
"icon": "$(new-folder)"
132+
},
127133
{
128134
"command": "python-envs.removePythonProject",
129135
"title": "%python-envs.removePythonProject.title%",
@@ -292,6 +298,10 @@
292298
"command": "python-envs.addPythonProject",
293299
"when": "false"
294300
},
301+
{
302+
"command": "python-envs.addPythonProjectGivenResource",
303+
"when": "false"
304+
},
295305
{
296306
"command": "python-envs.removePythonProject",
297307
"when": "false"
@@ -455,12 +465,12 @@
455465
],
456466
"explorer/context": [
457467
{
458-
"command": "python-envs.addPythonProject",
468+
"command": "python-envs.addPythonProjectGivenResource",
459469
"group": "inline",
460470
"when": "explorerViewletVisible && explorerResourceIsFolder && !python-envs:isExistingProject"
461471
},
462472
{
463-
"command": "python-envs.addPythonProject",
473+
"command": "python-envs.addPythonProjectGivenResource",
464474
"group": "inline",
465475
"when": "explorerViewletVisible && resourceExtname == .py && !python-envs:isExistingProject"
466476
}
@@ -560,4 +570,4 @@
560570
"vscode-jsonrpc": "^9.0.0-next.5",
561571
"which": "^4.0.0"
562572
}
563-
}
573+
}

package.nls.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"python-envs.terminal.revertStartupScriptChanges.title": "Revert Shell Startup Script Changes",
1414
"python-envs.setEnvManager.title": "Set Environment Manager",
1515
"python-envs.setPkgManager.title": "Set Package Manager",
16-
"python-envs.addPythonProject.title": "Add as Python Project",
16+
"python-envs.addPythonProject.title": "Add Python Project",
17+
"python-envs.addPythonProjectGivenResource.title": "Add as Python Project",
1718
"python-envs.removePythonProject.title": "Remove Python Project",
1819
"python-envs.copyEnvPath.title": "Copy Environment Path",
1920
"python-envs.copyProjectPath.title": "Copy Project Path",
@@ -35,4 +36,4 @@
3536
"python-envs.terminal.activate.title": "Activate Environment in Current Terminal",
3637
"python-envs.terminal.deactivate.title": "Deactivate Environment in Current Terminal",
3738
"python-envs.uninstallPackage.title": "Uninstall Package"
38-
}
39+
}

src/extension.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,10 @@ export async function activate(context: ExtensionContext): Promise<PythonEnviron
199199
commands.registerCommand('python-envs.setPkgManager', async () => {
200200
await setPackageManagerCommand(envManagers, projectManager);
201201
}),
202-
commands.registerCommand('python-envs.addPythonProject', async (resource) => {
202+
commands.registerCommand('python-envs.addPythonProject', async () => {
203+
await addPythonProjectCommand(undefined, projectManager, envManagers, projectCreators);
204+
}),
205+
commands.registerCommand('python-envs.addPythonProjectGivenResource', async (resource) => {
203206
// Set context to show/hide menu item depending on whether the resource is already a Python project
204207
if (resource instanceof Uri) {
205208
commands.executeCommand('setContext', 'python-envs:isExistingProject', isExistingProject(resource));

0 commit comments

Comments
 (0)