From 86b3d77a789c217d5e5b6990ab49a1f2bb0e7df3 Mon Sep 17 00:00:00 2001 From: "Travis C. LaGrone" <22419287+travis-c-lagrone@users.noreply.github.com> Date: Sun, 5 May 2019 03:51:37 -0500 Subject: [PATCH 1/3] Define snippet named 'ArgumentCompleterAttribute with ScriptBlock' --- snippets/PowerShell.json | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/snippets/PowerShell.json b/snippets/PowerShell.json index dd7317d89b..0a6cb128a3 100644 --- a/snippets/PowerShell.json +++ b/snippets/PowerShell.json @@ -1019,5 +1019,23 @@ "}$0" ], "description": "Pester - It block" + }, + "ArgumentCompleterAttribute with ScriptBlock": { + "prefix": "completer-attribute", + "body": [ + "[ArgumentCompleter({", + "\t[OutputType([System.Management.Automation.CompletionResult])] # zero to many", + "\tparam(", + "\t\t[string] \\$CommandName,", + "\t\t[string] \\$ParameterName,", + "\t\t[string] \\$WordToComplete,", + "\t\t[System.Management.Automation.Language.CommandAst] \\$CommandAst,", + "\t\t[System.Collections.IDictionary] \\$FakeBoundParameters", + "\t)", + "\t", + "\t${0:$TM_SELECTED_TEXT}", + "})]" + ], + "description": "ArgumentCompleter parameter attribute with script block definition" } } From 2660f6448c2dbfb91c9c9536ff927a3a3d92f461 Mon Sep 17 00:00:00 2001 From: "Travis C. LaGrone" <22419287+travis-c-lagrone@users.noreply.github.com> Date: Sun, 5 May 2019 04:10:52 -0500 Subject: [PATCH 2/3] Define snippet named 'IArgumentCompleter Class' --- snippets/PowerShell.json | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/snippets/PowerShell.json b/snippets/PowerShell.json index 0a6cb128a3..77aa2636ee 100644 --- a/snippets/PowerShell.json +++ b/snippets/PowerShell.json @@ -1037,5 +1037,26 @@ "})]" ], "description": "ArgumentCompleter parameter attribute with script block definition" + }, + "IArgumentCompleter Class": { + "prefix": "completer-class", + "body": [ + "class ${1:ArgumentCompleter} : System.Management.Automation.IArgumentCompleter {", + "\t[System.Collections.Generic.IEnumerable[System.Management.Automation.CompletionResult]] CompleteArgument(", + "\t\t[string] \\$CommandName,", + "\t\t[string] \\$ParameterName,", + "\t\t[string] \\$WordToComplete,", + "\t\t[System.Management.Automation.Language.CommandAst] \\$CommandAst,", + "\t\t[System.Collections.IDictionary] \\$FakeBoundParameters", + "\t) {", + "\t\t\\$CompletionResults = [System.Collections.Generic.List[System.Management.Automation.CompletionResult]]::new()", + "\t\t", + "\t\t${0:$TM_SELECTED_TEXT}", + "\t\t", + "\t\treturn \\$CompletionResults", + "\t}", + "}" + ], + "description": "IArgumentCompleter implementation class definition" } } From 8a0e7dc782d7061369a8fdbe5befc78b3b91d43c Mon Sep 17 00:00:00 2001 From: "Travis C. LaGrone" <22419287+travis-c-lagrone@users.noreply.github.com> Date: Sun, 5 May 2019 04:14:29 -0500 Subject: [PATCH 3/3] Define snippet named 'ArgumentCompleterAttribute ScriptBlock' --- snippets/PowerShell.json | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/snippets/PowerShell.json b/snippets/PowerShell.json index 77aa2636ee..a7fffc4551 100644 --- a/snippets/PowerShell.json +++ b/snippets/PowerShell.json @@ -1038,6 +1038,24 @@ ], "description": "ArgumentCompleter parameter attribute with script block definition" }, + "ArgumentCompleterAttribute ScriptBlock": { + "prefix": "completer-scriptblock", + "body": [ + "{", + "\t[OutputType([System.Management.Automation.CompletionResult])] # zero to many", + "\tparam(", + "\t\t[string] \\$CommandName,", + "\t\t[string] \\$ParameterName,", + "\t\t[string] \\$WordToComplete,", + "\t\t[System.Management.Automation.Language.CommandAst] \\$CommandAst,", + "\t\t[System.Collections.IDictionary] \\$FakeBoundParameters", + "\t)", + "\t", + "\t${0:$TM_SELECTED_TEXT}", + "}" + ], + "description": "ArgumentCompleter parameter attribute script block definition" + }, "IArgumentCompleter Class": { "prefix": "completer-class", "body": [