Skip to content

Commit 62bd18a

Browse files
committed
Add optional UI to prompt for script args.
1 parent 7821670 commit 62bd18a

File tree

3 files changed

+40
-3
lines changed

3 files changed

+40
-3
lines changed

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
"onCommand:PowerShell.NewProjectFromTemplate",
3131
"onCommand:PowerShell.OpenExamplesFolder",
3232
"onCommand:PowerShell.StartDebugSession",
33-
"onCommand:PowerShell.PickPSHostProcess"
33+
"onCommand:PowerShell.PickPSHostProcess",
34+
"onCommand:PowerShell.SpecifyScriptArgs"
3435
],
3536
"dependencies": {
3637
"vscode-languageclient": "1.3.1"
@@ -175,7 +176,8 @@
175176
"program": "./out/debugAdapter.js",
176177
"runtime": "node",
177178
"variables": {
178-
"PickPSHostProcess": "PowerShell.PickPSHostProcess"
179+
"PickPSHostProcess": "PowerShell.PickPSHostProcess",
180+
"SpecifyScriptArgs": "PowerShell.SpecifyScriptArgs"
179181
},
180182
"languages": [
181183
"powershell"

src/features/DebugSession.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,39 @@ export class DebugSessionFeature implements IFeature {
106106
}
107107
}
108108

109+
export class SpecifyScriptArgsFeature implements IFeature {
110+
111+
private command: vscode.Disposable;
112+
private languageClient: LanguageClient;
113+
114+
constructor() {
115+
116+
this.command =
117+
vscode.commands.registerCommand('PowerShell.SpecifyScriptArgs', () => {
118+
return this.specifyScriptArguments();
119+
});
120+
}
121+
122+
public setLanguageClient(languageclient: LanguageClient) {
123+
this.languageClient = languageclient;
124+
}
125+
126+
public dispose() {
127+
this.command.dispose();
128+
}
129+
130+
private specifyScriptArguments(): Thenable<string[]> {
131+
let options: vscode.InputBoxOptions = {
132+
ignoreFocusOut: true,
133+
placeHolder: "Enter script arguments"
134+
}
135+
136+
return vscode.window.showInputBox(options).then(text => {
137+
return text !== undefined ? new Array(text) : text;
138+
});
139+
}
140+
}
141+
109142
interface ProcessItem extends vscode.QuickPickItem {
110143
pid: string; // payload for the QuickPick UI
111144
}

src/main.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { CodeActionsFeature } from './features/CodeActions';
2121
import { RemoteFilesFeature } from './features/RemoteFiles';
2222
import { DebugSessionFeature } from './features/DebugSession';
2323
import { PickPSHostProcessFeature } from './features/DebugSession';
24+
import { SpecifyScriptArgsFeature } from './features/DebugSession';
2425
import { SelectPSSARulesFeature } from './features/SelectPSSARules';
2526
import { FindModuleFeature } from './features/PowerShellFindModule';
2627
import { NewFileOrProjectFeature } from './features/NewFileOrProject';
@@ -113,7 +114,8 @@ export function activate(context: vscode.ExtensionContext): void {
113114
new DocumentFormatterFeature(),
114115
new RemoteFilesFeature(),
115116
new DebugSessionFeature(),
116-
new PickPSHostProcessFeature()
117+
new PickPSHostProcessFeature(),
118+
new SpecifyScriptArgsFeature()
117119
];
118120

119121
sessionManager =

0 commit comments

Comments
 (0)