Skip to content

Commit 7bfcaee

Browse files
travisclagronerjmholt
authored andcommitted
Add ArgumentCompleter snippets (PowerShell#1946)
* Define snippet named 'ArgumentCompleterAttribute with ScriptBlock' * Define snippet named 'IArgumentCompleter Class' * Define snippet named 'ArgumentCompleterAttribute ScriptBlock'
1 parent 24e8e00 commit 7bfcaee

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

snippets/PowerShell.json

+57
Original file line numberDiff line numberDiff line change
@@ -1025,5 +1025,62 @@
10251025
"}$0"
10261026
],
10271027
"description": "Pester - It block"
1028+
},
1029+
"ArgumentCompleterAttribute with ScriptBlock": {
1030+
"prefix": "completer-attribute",
1031+
"body": [
1032+
"[ArgumentCompleter({",
1033+
"\t[OutputType([System.Management.Automation.CompletionResult])] # zero to many",
1034+
"\tparam(",
1035+
"\t\t[string] \\$CommandName,",
1036+
"\t\t[string] \\$ParameterName,",
1037+
"\t\t[string] \\$WordToComplete,",
1038+
"\t\t[System.Management.Automation.Language.CommandAst] \\$CommandAst,",
1039+
"\t\t[System.Collections.IDictionary] \\$FakeBoundParameters",
1040+
"\t)",
1041+
"\t",
1042+
"\t${0:$TM_SELECTED_TEXT}",
1043+
"})]"
1044+
],
1045+
"description": "ArgumentCompleter parameter attribute with script block definition"
1046+
},
1047+
"ArgumentCompleterAttribute ScriptBlock": {
1048+
"prefix": "completer-scriptblock",
1049+
"body": [
1050+
"{",
1051+
"\t[OutputType([System.Management.Automation.CompletionResult])] # zero to many",
1052+
"\tparam(",
1053+
"\t\t[string] \\$CommandName,",
1054+
"\t\t[string] \\$ParameterName,",
1055+
"\t\t[string] \\$WordToComplete,",
1056+
"\t\t[System.Management.Automation.Language.CommandAst] \\$CommandAst,",
1057+
"\t\t[System.Collections.IDictionary] \\$FakeBoundParameters",
1058+
"\t)",
1059+
"\t",
1060+
"\t${0:$TM_SELECTED_TEXT}",
1061+
"}"
1062+
],
1063+
"description": "ArgumentCompleter parameter attribute script block definition"
1064+
},
1065+
"IArgumentCompleter Class": {
1066+
"prefix": "completer-class",
1067+
"body": [
1068+
"class ${1:ArgumentCompleter} : System.Management.Automation.IArgumentCompleter {",
1069+
"\t[System.Collections.Generic.IEnumerable[System.Management.Automation.CompletionResult]] CompleteArgument(",
1070+
"\t\t[string] \\$CommandName,",
1071+
"\t\t[string] \\$ParameterName,",
1072+
"\t\t[string] \\$WordToComplete,",
1073+
"\t\t[System.Management.Automation.Language.CommandAst] \\$CommandAst,",
1074+
"\t\t[System.Collections.IDictionary] \\$FakeBoundParameters",
1075+
"\t) {",
1076+
"\t\t\\$CompletionResults = [System.Collections.Generic.List[System.Management.Automation.CompletionResult]]::new()",
1077+
"\t\t",
1078+
"\t\t${0:$TM_SELECTED_TEXT}",
1079+
"\t\t",
1080+
"\t\treturn \\$CompletionResults",
1081+
"\t}",
1082+
"}"
1083+
],
1084+
"description": "IArgumentCompleter implementation class definition"
10281085
}
10291086
}

0 commit comments

Comments
 (0)