From 5551f3c77a343c66482d9afecf73e05890059467 Mon Sep 17 00:00:00 2001 From: Staffan Gustafsson Date: Sat, 24 Feb 2018 15:57:49 +0100 Subject: [PATCH] Adding snippet for class based argument completion One completer with and one w/o example Also adding placeholders for the one without example --- snippets/PowerShell.json | 506 +++++++++++++++++++++++++++++++++------ 1 file changed, 431 insertions(+), 75 deletions(-) diff --git a/snippets/PowerShell.json b/snippets/PowerShell.json index 9fb67df773..5e939bf005 100644 --- a/snippets/PowerShell.json +++ b/snippets/PowerShell.json @@ -2,62 +2,62 @@ "ModuleManifest": { "prefix": "manifest", "body": [ - "@{", - "\t# If authoring a script module, the RootModule is the name of your .psm1 file", - "\tRootModule = '${module:MyModule}.psm1'", - "", - "\tAuthor = '${author:Cool Person }'", - "", - "\tCompanyName = '${company:Contoso Inc.}'", - "", - "\tModuleVersion = '${ModuleVersion:0.1}'", - "", - "\t# Use the New-Guid command to generate a GUID, and copy/paste into the next line", - "\tGUID = ''", - "", - "\tCopyright = '2017 ${company:Copyright Holder}'", - "", - "\tDescription = '${Description:What does this module do?}'", - "", - "\t# Minimum PowerShell version supported by this module (optional, recommended)", - "\t# PowerShellVersion = ''", - "", - "\t# Which PowerShell Editions does this module work with? (Core, Desktop)", - "\tCompatiblePSEditions = @('Desktop', 'Core')", - "", - "\t# Which PowerShell functions are exported from your module? (eg. Get-CoolObject)", - "\tFunctionsToExport = @('')", - "", - "\t# Which PowerShell aliases are exported from your module? (eg. gco)", - "\tAliasesToExport = @('')", - "", - "\t# Which PowerShell variables are exported from your module? (eg. Fruits, Vegetables)", - "\tVariablesToExport = @('')", - "", - "\t# PowerShell Gallery: Define your module's metadata", - "\tPrivateData = @{", - "\t\tPSData = @{", - "\t\t\t# What keywords represent your PowerShell module? (eg. cloud, tools, framework, vendor)", - "\t\t\tTags = @('${tag1:cooltag1}', '${tag2:cooltag2}')", - "", - "\t\t\t# What software license is your code being released under? (see https://opensource.org/licenses)", - "\t\t\tLicenseUri = ''", - "", - "\t\t\t# What is the URL to your project's website?", - "\t\t\tProjectUri = ''", - "", - "\t\t\t# What is the URI to a custom icon file for your project? (optional)", - "\t\t\tIconUri = ''", - "", - "\t\t\t# What new features, bug fixes, or deprecated features, are part of this release?", - "\t\t\tReleaseNotes = @'", - "'@", - "\t\t}", - "\t}", - "", - "\t# If your module supports updateable help, what is the URI to the help archive? (optional)", - "\t# HelpInfoURI = ''", - "}" + "@{", + "\t# If authoring a script module, the RootModule is the name of your .psm1 file", + "\tRootModule = '${module:MyModule}.psm1'", + "", + "\tAuthor = '${author:Cool Person }'", + "", + "\tCompanyName = '${company:Contoso Inc.}'", + "", + "\tModuleVersion = '${ModuleVersion:0.1}'", + "", + "\t# Use the New-Guid command to generate a GUID, and copy/paste into the next line", + "\tGUID = ''", + "", + "\tCopyright = '2017 ${company:Copyright Holder}'", + "", + "\tDescription = '${Description:What does this module do?}'", + "", + "\t# Minimum PowerShell version supported by this module (optional, recommended)", + "\t# PowerShellVersion = ''", + "", + "\t# Which PowerShell Editions does this module work with? (Core, Desktop)", + "\tCompatiblePSEditions = @('Desktop', 'Core')", + "", + "\t# Which PowerShell functions are exported from your module? (eg. Get-CoolObject)", + "\tFunctionsToExport = @('')", + "", + "\t# Which PowerShell aliases are exported from your module? (eg. gco)", + "\tAliasesToExport = @('')", + "", + "\t# Which PowerShell variables are exported from your module? (eg. Fruits, Vegetables)", + "\tVariablesToExport = @('')", + "", + "\t# PowerShell Gallery: Define your module's metadata", + "\tPrivateData = @{", + "\t\tPSData = @{", + "\t\t\t# What keywords represent your PowerShell module? (eg. cloud, tools, framework, vendor)", + "\t\t\tTags = @('${tag1:cooltag1}', '${tag2:cooltag2}')", + "", + "\t\t\t# What software license is your code being released under? (see https://opensource.org/licenses)", + "\t\t\tLicenseUri = ''", + "", + "\t\t\t# What is the URL to your project's website?", + "\t\t\tProjectUri = ''", + "", + "\t\t\t# What is the URI to a custom icon file for your project? (optional)", + "\t\t\tIconUri = ''", + "", + "\t\t\t# What new features, bug fixes, or deprecated features, are part of this release?", + "\t\t\tReleaseNotes = @'", + "'@", + "\t\t}", + "\t}", + "", + "\t# If your module supports updateable help, what is the URI to the help archive? (optional)", + "\t# HelpInfoURI = ''", + "}" ], "description": "Basic skeleton for a PowerShell module manifest, complete with PowerShell Gallery metadata." }, @@ -638,6 +638,362 @@ ], "description": "Parameter declaration snippet for a LiteralPath parameter" }, + "Example-Advanced-Argument-Completer": { + "prefix": "ex-advanced-argument-completer", + "body": [ + "using namespace System.Management.Automation", + "using namespace System.Collections.Generic", + "", + "class ArgumentCompleterBase : IArgumentCompleter {", + "\thidden [List[CompletionResult]] \\$Results = [List[CompletionResult]]::new()", + "\t[string] \\$WordToComplete", + "\t[Language.CommandAst] \\$commandAst", + "", + "\t# override in child class", + "\t[void] AddCompletionsFor([string] \\$commandName, [string] \\$parameterName, [Collections.IDictionary] \\$fakeBoundParameters) {}", + "", + "", + "\t[IEnumerable[CompletionResult]]", + "\tCompleteArgument([string] \\$commandName, [string] \\$parameterName, [string] \\$wordToComplete,", + "\t\t[Language.CommandAst] \\$commandAst,", + "\t\t[Collections.IDictionary] \\$fakeBoundParameters) {", + "\t\t\\$this.WordToComplete = \\$wordToComplete", + "\t\t\\$this.CommandAst = \\$commandAst", + "\t\t\\$this.AddCompletionsFor(\\$commandName, \\$parameterName, \\$fakeBoundParameters)", + "\t\treturn \\$this.Results", + "\t}", + "\t", + "\t\u003c#", + "\t\tAdds a completion result to the result set", + "\t#\u003e", + "\t[void] CompleteWith([CompletionResult] \\$completionResult) {", + "\t\t\\$this.Results.Add(\\$completionResult)", + "\t}", + "", + "\t[void] CompleteWith([string] \\$text) {", + "\t\t\\$this.CompleteWith(\\$text, \\$text, \\$text, [CompletionResultType]::ParameterValue)", + "\t}", + "\t[void] CompleteWith([string] \\$text, [string] \\$tooltip) {", + "\t\t\\$this.CompleteWith(\\$text, \\$text, \\$tooltip, [CompletionResultType]::ParameterValue)", + "\t}", + "\t[void] CompleteWith([string] \\$text, [string] \\$listItemText, [string] \\$toolTip) {", + "\t\t\\$this.CompleteWith(\\$text, \\$listItemText, \\$tooltip, [CompletionResultType]::ParameterValue)", + "\t}", + "\t[void] CompleteWith([string] \\$text, [string] \\$listItemText, [string] \\$toolTip, [CompletionResultType] \\$resultType) {", + "\t\t\\$quotedText = [ArgumentCompleterBase]::QuoteTextWithSpace(\\$text)", + "\t\tif (\\$null -eq \\$listItemText) {", + "\t\t\t\\$listItemText = \\$text", + "\t\t}", + "\t\tif (\\$null -eq \\$toolTip) {", + "\t\t\t\\$toolTip = \\$text", + "\t\t}", + "\t\t\\$cr = [CompletionResult]::new(\\$quotedText, \\$listItemText, \\$resultType, \\$toolTip)", + "\t\t\\$this.Results.Add(\\$cr)", + "\t}", + "", + "\t\u003c#", + "\t\tAdds a completion result to the result set if \\$text starts with WordToComplete ", + "\t#\u003e", + "\t[void] CompleteWithIfStartsWithWordToComplete([string] \\$text) {", + "\t\t\\$this.CompleteWithIfStartsWithWordToComplete(\\$text, \\$text, \\$text, [CompletionResultType]::ParameterValue)", + "\t}", + "\t[void] CompleteWithIfStartsWithWordToComplete([string] \\$text, [string] \\$tooltip) {", + "\t\t\\$this.CompleteWithIfStartsWithWordToComplete(\\$text, \\$text, \\$tooltip, [CompletionResultType]::ParameterValue)", + "\t}", + "\t[void] CompleteWithIfStartsWithWordToComplete([string] \\$text, [string] \\$listItemText, [string] \\$toolTip) {", + "\t\t\\$this.CompleteWithIfStartsWithWordToComplete(\\$text, \\$listItemText, \\$tooltip, [CompletionResultType]::ParameterValue)", + "\t}", + "\t[void] CompleteWithIfStartsWithWordToComplete([string] \\$text, [string] \\$listItemText, [string] \\$toolTip, [CompletionResultType] \\$resultType) {", + "\t\tif (\\$this.StartsWithWordToComplete(\\$text)){", + "\t\t\t\\$this.CompleteWith(\\$text, \\$listItemText, \\$toolTip, \\$resultType)", + "\t\t}", + "\t}", + "", + "\t\u003c#", + "\t\tAdds a completion result to the result set if \\$text contains WordToComplete", + "\t#\u003e", + "\t[void] CompleteWithIfTextContainsWordToComplete([string] \\$text) {", + "\t\t\\$this.CompleteWithIfTextContainsWordToComplete(\\$text, \\$text, \\$text, [CompletionResultType]::ParameterValue)", + "\t}", + "\t[void] CompleteWithIfTextContainsWordToComplete([string] \\$text, [string] \\$tooltip) {", + "\t\t\\$this.CompleteWithIfTextContainsWordToComplete(\\$text, \\$text, \\$tooltip, [CompletionResultType]::ParameterValue)", + "\t}", + "\t[void] CompleteWithIfTextContainsWordToComplete([string] \\$text, [string] \\$listItemText, [string] \\$toolTip) {", + "\t\t\\$this.CompleteWithIfTextContainsWordToComplete(\\$text, \\$listItemText, \\$tooltip, [CompletionResultType]::ParameterValue)", + "\t}", + "\t[void] CompleteWithIfTextContainsWordToComplete([string] \\$text, [string] \\$listItemText, [string] \\$toolTip, [CompletionResultType] \\$resultType) {", + "\t\tif (\\$this.ContainsWordToComplete(\\$text)){", + "\t\t\t\\$this.CompleteWith(\\$text, \\$listItemText, \\$toolTip, \\$resultType)", + "\t\t}", + "\t}", + "", + "\t[bool] StartsWithWordToComplete([string] \\$text) {", + "\t\treturn \\$text.StartsWith(\\$this.WordToComplete, [StringComparison]::CurrentCultureIgnoreCase)", + "\t}", + "\t[bool] StartsWithWordToComplete([string] \\$text, [StringComparison] \\$comparison) {", + "\t\treturn \\$text.StartsWith(\\$this.WordToComplete, \\$comparison)", + "\t}", + "\t[bool] ContainsWordToComplete([string] \\$text) {", + "\t\treturn \\$text.IndexOf(\\$this.WordToComplete, [StringComparison]::CurrentCultureIgnoreCase) -ne -1", + "\t}", + "\t[bool] ContainsWordToComplete([string] \\$text, [StringComparison] \\$comparison) {", + "\t\treturn \\$text.IndexOf(\\$this.WordToComplete, \\$comparison) -ne -1", + "\t}", + "", + "\thidden static [string] QuoteTextWithSpace([string] \\$text) {", + "\t\tif (\\$text.IndexOf(\" \") -ne -1) {", + "\t\t\treturn \"\"\"\\$text\"\"\"", + "\t\t}", + "\t\treturn \\$text", + "\t}", + "}", + "", + "#region example usage", + "class CustomArgumentCompleter : ArgumentCompleterBase {", + "", + "\t# override", + "\t[void] AddCompletionsFor([string] \\$commandName, [string] \\$parameterName, [Collections.IDictionary] \\$fakeBoundParameters) {", + "\t\tswitch (\"\\${commandName}:\\$parameterName\") {", + "\t\t\t# handle completion based on both command and parameter name", + "\t\t\t\"Get-Account:Client\" {", + "\t\t\t\t\\$this.CompleteAccountClient(\\$fakeBoundParameters)", + "\t\t\t\tbreak", + "\t\t\t}", + "\t\t\tdefault {", + "\t\t\t\t# handle generic parameter completion", + "\t\t\t\tswitch (\\$parameterName) {", + "\t\t\t\t\t\"Client\" {", + "\t\t\t\t\t\t\\$this.CompleteClient(\\$fakeBoundParameters)", + "\t\t\t\t\t\tbreak", + "\t\t\t\t\t}", + "\t\t\t\t}", + "\t\t\t}", + "\t\t}", + "\t}", + "", + "\t[void] CompleteAccountClient([Collections.IDictionary] \\$fakeBoundParameter) {", + "\t\t# Get-Client knows how to get clients", + "\t\t\\$clients = [client]::GetAll()", + "\t\tforeach (\\$client in \\$clients) {", + "\t\t\t# complete with this name if wordToComplete is anywhere in \\$client.Name", + "\t\t\t\\$this.CompleteWithIfTextContainsWordToComplete(\\$client.Name)", + "\t\t}", + "\t}", + "", + "\t[void] CompleteClient([Collections.IDictionary] \\$fakeBoundParameter) {", + "\t\t# Get-Client knows how to get clients", + "\t\t\\$clients = [Client]::GetAll()", + "\t\tforeach (\\$client in \\$clients) {", + "\t\t\t# complete with this name and description if \\$client.Name starts with wordToComplete", + "\t\t\t\\$this.CompleteWithIfStartsWithWordToComplete(\\$client.Name, \\$client.Description)", + "\t\t}", + "\t}", + "}", + "", + "", + "class Client {", + "\t[string] \\$Name", + "\t[string] \\$Description", + "", + "\tstatic [Client[]] GetAll() {", + "\t\t\\$clients = foreach (\\$name in \u0027Steve\u0027, \u0027Joey\u0027, \u0027Jeffrey\u0027, \u0027Jason Shirk\u0027, \u0027Bruce Payette\u0027) { ", + "\t\t\t[Client] @{ Name = \\$name; Description = \"Descrption of \\$name\" } ", + "\t\t}", + "\t\treturn \\$clients", + "\t}", + "", + "\t[string] ToString() {", + "\t\treturn \"Client for \\$(\\$this.Name)\"", + "\t}", + "}", + "", + "class Account {", + "\t[string] \\$Description", + "}", + "", + "function Get-Client {", + "\t[OutputType([Client])]", + "\tparam(", + "\t\t[ArgumentCompleter([CustomArgumentCompleter])]", + "\t\t[Parameter(Mandatory)]", + "\t\t[string] \\$Client", + "\t)", + "\tforeach (\\$c in [Client]::GetAll()) { ", + "\t\tif (\\$Client -eq \\$c.Name) {", + "\t\t\t\\$c", + "\t\t}", + "\t}", + "}", + "", + "function Get-Account {", + "\t[OutputType([Account])]", + "\tparam(", + "\t\t[Parameter(Mandatory)]", + "\t\t[ArgumentCompleter([CustomArgumentCompleter])]", + "\t\t[string] \\$Client", + "\t)", + "\t\\$c = Get-Client -Client \\$Client", + "\t[Account] @{", + "\t\tDescription = \"Account for \\$c\"", + "\t}", + "}", + "", + "#endregion" + ], + "description": "example of class based argument completer" + }, + "Advanced-Argument-Completer": { + "prefix": "advanced-argument-completer", + "body": [ + "using namespace System.Management.Automation", + "using namespace System.Collections.Generic", + "", + "class ArgumentCompleterBase : IArgumentCompleter {", + "\thidden [List[CompletionResult]] \\$Results = [List[CompletionResult]]::new()", + "\t[string] \\$WordToComplete", + "\t[Language.CommandAst] \\$commandAst", + "", + "\t# override in child class", + "\t[void] AddCompletionsFor([string] \\$commandName, [string] \\$parameterName, [Collections.IDictionary] \\$fakeBoundParameters) {}", + "", + "", + "\t[IEnumerable[CompletionResult]]", + "\tCompleteArgument([string] \\$commandName, [string] \\$parameterName, [string] \\$wordToComplete,", + "\t\t[Language.CommandAst] \\$commandAst,", + "\t\t[Collections.IDictionary] \\$fakeBoundParameters) {", + "\t\t\\$this.WordToComplete = \\$wordToComplete", + "\t\t\\$this.CommandAst = \\$commandAst", + "\t\t\\$this.AddCompletionsFor(\\$commandName, \\$parameterName, \\$fakeBoundParameters)", + "\t\treturn \\$this.Results", + "\t}", + "\t", + "\t\u003c#", + "\t\tAdds a completion result to the result set", + "\t#\u003e", + "\t[void] CompleteWith([CompletionResult] \\$completionResult) {", + "\t\t\\$this.Results.Add(\\$completionResult)", + "\t}", + "", + "\t[void] CompleteWith([string] \\$text) {", + "\t\t\\$this.CompleteWith(\\$text, \\$text, \\$text, [CompletionResultType]::ParameterValue)", + "\t}", + "\t[void] CompleteWith([string] \\$text, [string] \\$tooltip) {", + "\t\t\\$this.CompleteWith(\\$text, \\$text, \\$tooltip, [CompletionResultType]::ParameterValue)", + "\t}", + "\t[void] CompleteWith([string] \\$text, [string] \\$listItemText, [string] \\$toolTip) {", + "\t\t\\$this.CompleteWith(\\$text, \\$listItemText, \\$tooltip, [CompletionResultType]::ParameterValue)", + "\t}", + "\t[void] CompleteWith([string] \\$text, [string] \\$listItemText, [string] \\$toolTip, [CompletionResultType] \\$resultType) {", + "\t\t\\$quotedText = [ArgumentCompleterBase]::QuoteTextWithSpace(\\$text)", + "\t\tif (\\$null -eq \\$listItemText) {", + "\t\t\t\\$listItemText = \\$text", + "\t\t}", + "\t\tif (\\$null -eq \\$toolTip) {", + "\t\t\t\\$toolTip = \\$text", + "\t\t}", + "\t\t\\$cr = [CompletionResult]::new(\\$quotedText, \\$listItemText, \\$resultType, \\$toolTip)", + "\t\t\\$this.Results.Add(\\$cr)", + "\t}", + "", + "\t\u003c#", + "\t\tAdds a completion result to the result set if \\$text starts with WordToComplete ", + "\t#\u003e", + "\t[void] CompleteWithIfStartsWithWordToComplete([string] \\$text) {", + "\t\t\\$this.CompleteWithIfStartsWithWordToComplete(\\$text, \\$text, \\$text, [CompletionResultType]::ParameterValue)", + "\t}", + "\t[void] CompleteWithIfStartsWithWordToComplete([string] \\$text, [string] \\$tooltip) {", + "\t\t\\$this.CompleteWithIfStartsWithWordToComplete(\\$text, \\$text, \\$tooltip, [CompletionResultType]::ParameterValue)", + "\t}", + "\t[void] CompleteWithIfStartsWithWordToComplete([string] \\$text, [string] \\$listItemText, [string] \\$toolTip) {", + "\t\t\\$this.CompleteWithIfStartsWithWordToComplete(\\$text, \\$listItemText, \\$tooltip, [CompletionResultType]::ParameterValue)", + "\t}", + "\t[void] CompleteWithIfStartsWithWordToComplete([string] \\$text, [string] \\$listItemText, [string] \\$toolTip, [CompletionResultType] \\$resultType) {", + "\t\tif (\\$this.StartsWithWordToComplete(\\$text)){", + "\t\t\t\\$this.CompleteWith(\\$text, \\$listItemText, \\$toolTip, \\$resultType)", + "\t\t}", + "\t}", + "", + "\t\u003c#", + "\t\tAdds a completion result to the result set if \\$text contains WordToComplete", + "\t#\u003e", + "\t[void] CompleteWithIfTextContainsWordToComplete([string] \\$text) {", + "\t\t\\$this.CompleteWithIfTextContainsWordToComplete(\\$text, \\$text, \\$text, [CompletionResultType]::ParameterValue)", + "\t}", + "\t[void] CompleteWithIfTextContainsWordToComplete([string] \\$text, [string] \\$tooltip) {", + "\t\t\\$this.CompleteWithIfTextContainsWordToComplete(\\$text, \\$text, \\$tooltip, [CompletionResultType]::ParameterValue)", + "\t}", + "\t[void] CompleteWithIfTextContainsWordToComplete([string] \\$text, [string] \\$listItemText, [string] \\$toolTip) {", + "\t\t\\$this.CompleteWithIfTextContainsWordToComplete(\\$text, \\$listItemText, \\$tooltip, [CompletionResultType]::ParameterValue)", + "\t}", + "\t[void] CompleteWithIfTextContainsWordToComplete([string] \\$text, [string] \\$listItemText, [string] \\$toolTip, [CompletionResultType] \\$resultType) {", + "\t\tif (\\$this.ContainsWordToComplete(\\$text)){", + "\t\t\t\\$this.CompleteWith(\\$text, \\$listItemText, \\$toolTip, \\$resultType)", + "\t\t}", + "\t}", + "", + "\t[bool] StartsWithWordToComplete([string] \\$text) {", + "\t\treturn \\$text.StartsWith(\\$this.WordToComplete, [StringComparison]::CurrentCultureIgnoreCase)", + "\t}", + "\t[bool] StartsWithWordToComplete([string] \\$text, [StringComparison] \\$comparison) {", + "\t\treturn \\$text.StartsWith(\\$this.WordToComplete, \\$comparison)", + "\t}", + "\t[bool] ContainsWordToComplete([string] \\$text) {", + "\t\treturn \\$text.IndexOf(\\$this.WordToComplete, [StringComparison]::CurrentCultureIgnoreCase) -ne -1", + "\t}", + "\t[bool] ContainsWordToComplete([string] \\$text, [StringComparison] \\$comparison) {", + "\t\treturn \\$text.IndexOf(\\$this.WordToComplete, \\$comparison) -ne -1", + "\t}", + "", + "\thidden static [string] QuoteTextWithSpace([string] \\$text) {", + "\t\tif (\\$text.IndexOf(\" \") -ne -1) {", + "\t\t\treturn \"\"\"\\$text\"\"\"", + "\t\t}", + "\t\treturn \\$text", + "\t}", + "}", + "", + "class ${1:Custom}ArgumentCompleter : ArgumentCompleterBase {", + "\t# override", + "\t[void] AddCompletionsFor([string] \\$commandName, [string] \\$parameterName, [Collections.IDictionary] \\$fakeBoundParameters) {", + "\t\tswitch (\"\\${commandName}:\\$parameterName\") {", + "\t\t\t# handle completion based on both command and parameter name", + "\t\t\t\"${2:Verb-Noun:ParamName}\" {", + "\t\t\t\t\\$this.Complete${3:VerbNounParam}(\\$fakeBoundParameters)", + "\t\t\t\tbreak", + "\t\t\t}", + "\t\t\t#", + "\t\t\t# Add one switch clases for each parameter with generic completion", + "\t\t\t#", + "\t\t\t$0", + "\t\t\tdefault {", + "\t\t\t\t# handle generic parameter completion", + "\t\t\t\tswitch (\\$parameterName) {", + "\t\t\t\t\t\"${4:ParameterName}\" {", + "\t\t\t\t\t\t\\$this.Complete${4:ParameterName}(\\$fakeBoundParameters)", + "\t\t\t\t\t\tbreak", + "\t\t\t\t\t}", + "\t\t\t\t\t#", + "\t\t\t\t\t# Add one switch clases for each parameter with generic completion", + "\t\t\t\t\t#", + "\t\t\t\t}", + "\t\t\t}", + "\t\t}", + "\t}", + "", + "\t[void] Complete${3:VerbNounParam}([Collections.IDictionary] \\$fakeBoundParameter) {", + "\t\t# complete with \"completiontext\" if wordToComplete is anywhere in \"completiontext\"", + "\t\t#\\$this.CompleteWithIfTextContainsWordToComplete(\"completiontext\")", + "\t}", + "", + "\t[void] Complete${4:ParameterName}([Collections.IDictionary] \\$fakeBoundParameter) {", + "\t\t# complete some ${4:ParameterName}s that starts with wordToComplete", + "\t\t#\\$this.CompleteWithIfStartsWithWordToComplete(\"Some ${4:ParameterName}\")", + "\t}", + "}", + "" + ], + "description": "class based argument completer" + }, "DSC Ensure Enum": { "prefix": "DSC Ensure enum", "body": [ @@ -894,24 +1250,24 @@ "description": "sequence snippet (for use inside a workflow)" }, "Suppress PSScriptAnalyzer Rule": { - "prefix": "suppress-message-rule", - "description": "Suppress a built-in PSScriptAnalyzer rule using the SuppressMessageAttribute", - "body": [ - "[Diagnostics.CodeAnalysis.SuppressMessageAttribute('${1:PSUseDeclaredVarsMoreThanAssignments}', '')]" - ] - }, + "prefix": "suppress-message-rule", + "description": "Suppress a built-in PSScriptAnalyzer rule using the SuppressMessageAttribute", + "body": [ + "[Diagnostics.CodeAnalysis.SuppressMessageAttribute('${1:PSUseDeclaredVarsMoreThanAssignments}', '')]" + ] + }, "Suppress PSScriptAnalyzer Rule on Parameter": { - "prefix": "suppress-message-rule-for-parameter", - "description": "Suppress a built-in PSScriptAnalyzer rule on a parameter using the SuppressMessageAttribute", - "body": [ - "[Diagnostics.CodeAnalysis.SuppressMessageAttribute('${1:PSUseDeclaredVarsMoreThanAssignments}', '${2:ParamName}')]" - ] - }, - "Suppress PSScriptAnalyzer Rule in Scope": { - "prefix": "suppress-message-rule-for-scope", - "description": "Suppress a built-in PSScriptAnalyzer rule for functions or classes in a specific scope using the SuppressMessageAttribute", - "body": [ - "[Diagnostics.CodeAnalysis.SuppressMessageAttribute('${1:PSProvideDefaultParameterValue}', '', Scope='Function', Target='${2:*}')]" - ] - } + "prefix": "suppress-message-rule-for-parameter", + "description": "Suppress a built-in PSScriptAnalyzer rule on a parameter using the SuppressMessageAttribute", + "body": [ + "[Diagnostics.CodeAnalysis.SuppressMessageAttribute('${1:PSUseDeclaredVarsMoreThanAssignments}', '${2:ParamName}')]" + ] + }, + "Suppress PSScriptAnalyzer Rule in Scope": { + "prefix": "suppress-message-rule-for-scope", + "description": "Suppress a built-in PSScriptAnalyzer rule for functions or classes in a specific scope using the SuppressMessageAttribute", + "body": [ + "[Diagnostics.CodeAnalysis.SuppressMessageAttribute('${1:PSProvideDefaultParameterValue}', '', Scope='Function', Target='${2:*}')]" + ] + } }