-
Notifications
You must be signed in to change notification settings - Fork 513
Add an extended Snippet for Advanced Functions fixes #5197 #5203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kilasuit
wants to merge
8
commits into
PowerShell:main
Choose a base branch
from
kilasuit:5197
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1472f63
Add an extended Snippet for Advanced Functions fixes #5197
kilasuit 90f312b
missed the escape chars
kilasuit fca641c
Name and prefix update
kilasuit 42e594b
address comments
kilasuit a8bacf6
add new param with link to Argument Completer Docs
kilasuit 3edda97
🤦🏻♂️ spellings, if only I could nto mkae dez mistakes 🤦🏻♂️
kilasuit 788eab1
add multiple function aliases to show how to used them
kilasuit 04eb12b
drop use of $true for param attributes
kilasuit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -238,6 +238,100 @@ | |
"\t}", | ||
"}" | ||
] | ||
}, | ||
"Function-Advanced-Doc-Full-Example-From-ISE": { | ||
"prefix": ["function-advanced-doc-fromISE", "cmdlet-doc-fromISE"], | ||
"description": "Script advanced function definition with full comment-based help and parameter attributes.", | ||
"body": [ | ||
"function ${1:Verb-Noun} {", | ||
"\t<#", | ||
"\t.SYNOPSIS", | ||
"\tShort description", | ||
"\t.DESCRIPTION", | ||
"\tLong description", | ||
"\t.EXAMPLE", | ||
"\tExample of how to use this cmdlet", | ||
"\t.EXAMPLE", | ||
"\tAnother example of how to use this cmdlet", | ||
"\t.INPUTS", | ||
"\tInputs to this cmdlet (if any)", | ||
"\t.OUTPUTS", | ||
"\tOutput from this cmdlet (if any)", | ||
"\t.NOTES", | ||
"\tGeneral notes", | ||
"\t.COMPONENT", | ||
"\tThe component this cmdlet belongs to", | ||
"\t.ROLE", | ||
"\tThe role this cmdlet belongs to", | ||
"\t.FUNCTIONALITY", | ||
"\tThe functionality that best describes this cmdlet", | ||
"\t#>", | ||
"\t[CmdletBinding(DefaultParameterSetName = 'Parameter Set 1',", | ||
"\t\tSupportsShouldProcess,", | ||
"\t\tPositionalBinding", | ||
"\t\tHelpUri = 'http://yourwebsiteforhelp.here',", | ||
"\t\tConfirmImpact = 'Medium')]", | ||
"\t[Alias('Be-lazyWithThis','lzy','Use-OldFunctionName')]", | ||
"\t[OutputType([String])]", | ||
"\tparam (", | ||
"\t\t# Param1 help description", | ||
"\t\t[Parameter(Mandatory,", | ||
"\t\t\tValueFromPipeline,", | ||
"\t\t\tValueFromPipelineByPropertyName,", | ||
"\t\t\tValueFromRemainingArguments,", | ||
"\t\t\tPosition = 0,", | ||
"\t\t\tParameterSetName = 'Parameter Set 1')]", | ||
"\t\t[ValidateNotNull()]", | ||
"\t\t[ValidateNotNullOrEmpty()]", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aren't these two attributes overlapping? Or are you trying to have a snippet that shows all possible options? |
||
"\t\t[ValidateCount(0, 5)]", | ||
"\t\t[ValidateSet(\"sun\", \"moon\", \"earth\")]", | ||
"\t\t[Alias(\"p1\")]", | ||
"\t\t\\$Param1,", | ||
"", | ||
"\t\t# Param2 help description", | ||
"\t\t[Parameter(ParameterSetName = 'Parameter Set 1')]", | ||
"\t\t[AllowNull()]", | ||
"\t\t[AllowEmptyCollection()]", | ||
"\t\t[AllowEmptyString()]", | ||
"\t\t[ValidateScript({ \\$true })]", | ||
"\t\t[ValidateRange(0, 5)]", | ||
"\t\t[int]", | ||
"\t\t\\$Param2,", | ||
"", | ||
"\t\t# Param3 help description", | ||
"\t\t[Parameter(ParameterSetName = 'Another Parameter Set')]", | ||
"\t\t[ValidatePattern(\"[a-z]*\")]", | ||
"\t\t[ValidateLength(0, 15)]", | ||
"\t\t[String]", | ||
"\t\t\\$Param3", | ||
"", | ||
"\t\t# Checkout the docs https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_functions_argument_completion?view=powershell-7.5#argumentcompletions-attribute on different ways to provide Argument Completion", | ||
"\t\t[Parameter(ParameterSetName = 'Yet Another Parameter Set')]", | ||
"\t\t[ArgumentCompleter({'add completer script'})]", | ||
"\t\t[ValidateLength(0, 15)]", | ||
"\t\t[String]", | ||
"\t\t\\$Param4", | ||
"\t)", | ||
"", | ||
"\tbegin {", | ||
"\t\t#BeginCodeHere", | ||
"\t}", | ||
"", | ||
"\tprocess {", | ||
"\t\tif (\\$pscmdlet.ShouldProcess(\"Target\", \"Operation\")) {", | ||
"\t\t\t#ProcessCodeHere", | ||
"\t\t}", | ||
"\t}", | ||
"", | ||
"\tend {", | ||
"\t\t#EndCodeHere", | ||
"\t}", | ||
"", | ||
"\tclean {", | ||
"\t\t#CleanCodeHere - Added in 7.3 for more information see https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_functions_advanced_methods?view=powershell-7.5#clean", | ||
"\t}", | ||
"}" | ||
] | ||
}, | ||
"Function-Inline": { | ||
"prefix": "function-inline", | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.