Skip to content

Commit d71021b

Browse files
JustinGroteandyleejordan
authored andcommitted
ArgumentCompleterAttribute
1 parent 9a9c443 commit d71021b

File tree

1 file changed

+8
-25
lines changed

1 file changed

+8
-25
lines changed

snippets/PowerShell.json

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,11 @@
11
// The "Requires *" snippets should be removed if-and-when intellisense is implemented for the script requirement directive syntax.
22
{
3-
"ArgumentCompleterAttribute ScriptBlock": {
4-
"prefix": "completer-scriptblock",
5-
"description": "ArgumentCompleter parameter attribute script block definition",
6-
"body": [
7-
"{",
8-
"\t[OutputType([System.Management.Automation.CompletionResult])] # zero to many",
9-
"\tparam(",
10-
"\t\t[string] \\$CommandName,",
11-
"\t\t[string] \\$ParameterName,",
12-
"\t\t[string] \\$WordToComplete,",
13-
"\t\t[System.Management.Automation.Language.CommandAst] \\$CommandAst,",
14-
"\t\t[System.Collections.IDictionary] \\$FakeBoundParameters",
15-
"\t)",
16-
"\t",
17-
"\t${0:$TM_SELECTED_TEXT}",
18-
"}"
19-
]
20-
},
21-
"ArgumentCompleterAttribute with ScriptBlock": {
22-
"prefix": "completer-attribute",
23-
"description": "ArgumentCompleter parameter attribute with script block definition",
3+
"ArgumentCompleterAttribute": {
4+
"prefix": "argumentcompleter",
5+
"description": "The ArgumentCompleter attribute allows you to add tab completion values to a specific parameter by writing a scriptblock that generates zero or more CompletionResult objects. More: Get-Help -Online about_functions_argument_completion",
246
"body": [
257
"[ArgumentCompleter({",
26-
"\t[OutputType([System.Management.Automation.CompletionResult])] # zero to many",
8+
"\t[OutputType([System.Management.Automation.CompletionResult])]",
279
"\tparam(",
2810
"\t\t[string] \\$CommandName,",
2911
"\t\t[string] \\$ParameterName,",
@@ -32,8 +14,9 @@
3214
"\t\t[System.Collections.IDictionary] \\$FakeBoundParameters",
3315
"\t)",
3416
"\t",
35-
"\t${0:$TM_SELECTED_TEXT}",
36-
"})]"
17+
"\t${1:$TM_SELECTED_TEXT}",
18+
"\t#Output one or more of these objects: [Management.Automation.CompletionResult]'MyPotentialResult'",
19+
"})]${0}"
3720
]
3821
},
3922
"CalculatedProperty": {
@@ -625,7 +608,7 @@
625608
},
626609
"function": {
627610
"prefix": "function",
628-
"description": "Function definition snippet that contains a param block",
611+
"description": "A simple function with a parameter block to specify function arguments",
629612
"body": [
630613
"function ${1:FunctionName} {",
631614
"\tparam (",

0 commit comments

Comments
 (0)