Skip to content
This repository was archived by the owner on Jun 2, 2023. It is now read-only.

Updated 'Function' Snippets #47

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion snippets/language-powershell.cson
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@
'body': '.SYNOPSIS\n'
'Function Cmdlet':
'prefix': 'func'
'body': '<#\n.SYNOPSIS\n\tShort description\n\n.DESCRIPTION\n\tLong description\n\n.OUTPUTS\n\tThe value returned by this cmdlet\n\n.EXAMPLE\n\tExample of how to use this cmdlet\n\n.LINK\n\tTo other relevant cmdlets or help\n#>\nFunction ${1:Verb}-${2:Noun}\n{\n\t[CmdletBinding()]\n\t[OutputType([Nullable])]\n\tParam\n\t(\n\t\t# Param1 help description\n\t\t[Parameter(Mandatory, ValueFromPipelineByPropertyName, Position=0)]\n\t\t\$Param1,\n\n\t\t# Param2 help description\n\t\t[int]\n\t\t\$Param2\n\t)\n\tBegin\n\t{\n\t\t${3:# code}\n\t}\n\tProcess\n\t{\n\t}\n\tEnd\n\t{\n\t}\n}'
'body': 'Function ${1:Verb}-${2:Noun} {\n\n<#\n.SYNOPSIS\n\tA brief description of the function or script.\n\n.DESCRIPTION\n\tA detaild description of the function or script.\n\n.PARAMETER Param1\n\tThe description of a parameter. Add a .PARAMETER keyword for each parameter in the function or script syntax.\n\n.PARAMETER Param2\n\tThe description of a parameter.\n\n.INPUTS\n\tThe object input type/s accepted by this cmdlet\n\t(EX: [System.String],[System.Int32])\n\n.OUTPUTS\n\tThe object output type returned by this cmdlet\n\n.EXAMPLE\n\tExample of how to use this cmdlet\n\n.NOTES\n\tAdditional information about the function or script.\n\n.LINK\n\tabout_functions_advanced\n\n.LINK\n\tabout_comment_based_help\n\n.LINK\n\tabout_functions_advanced_parameters\n#>\n\n\t[CmdletBinding()]\n\t[OutputType([System.Nullable])]\n\tParam\n\t(\n\t\t[Parameter(Position=0, Mandatory=$true)]\n\t\t\[System.String]$Param1,\n\n\t\t[Parameter(Position=1, Mandatory=$false)]\n\t\t[System.Int32]$Param2\n\t)\n\n\tBEGIN {\n\n\t\t # run this code to setup environment\n\n\t} # end BEGIN block\n\n\tPROCESS {\n\n\t\t # production code\n\n\t} # end PROCESS block\n\n\tEND {\n\n\t\t # cleanup code\n\n\t} # end END block\n\n} # end function Verb-Noun'
'Advanced Function Cmdlet':
'prefix': 'funcadv'
'body': 'Function ${1:Verb}-${2:Noun} {\n\n<#\n.SYNOPSIS\n\tA brief description of the function or script.\n\n.DESCRIPTION\n\tA detaild description of the function or script.\n\n.PARAMETER Param1\n\tThe description of a parameter. Add a .PARAMETER keyword for each parameter in the function or script syntax.\n\n.PARAMETER Param2\n\tThe description of a parameter.\n\n.INPUTS\n\tThe object input type/s accepted by this cmdlet\n\t(EX: [System.String],[System.Int32])\n\n.OUTPUTS\n\tThe object output type returned by this cmdlet\n\n.EXAMPLE\n\tExample of how to use this cmdlet\n\n.NOTES\n\tAdditional information about the function or script.\n\n.LINK\n\tabout_functions_advanced\n\n.LINK\n\tabout_comment_based_help\n\n.LINK\n\tabout_functions_advanced_parameters\n#>\n\n\t[CmdletBinding()]\n\t[OutputType([System.Nullable])]\n\tParam\n\t(\n\t\t[Parameter(Position=0, Mandatory=$true)]\n\t\t\[System.String]$Param1,\n\n\t\t[Parameter(Position=1, Mandatory=$false)]\n\t\t[System.Int32]$Param2\n\t)\n\n\tBEGIN {\n\n\t\ttry {\n\n\t\t\t # try executing this code\n\n\t\t} catch {\n\n\t\t\t # catch errors; execute this code\n\n\t\t} # end try/catch\n\n\t} # end BEGIN block\n\n\tPROCESS {\n\n\t\ttry {\n\n\t\t\t # try executing this code\n\n\t\t} catch {\n\n\t\t\t # catch errors; execute this code\n\n\t\t} # end try/catch\n\n\t} # end PROCESS block\n\n\tEND {\n\n\t\ttry {\n\n\t\t\t # try executing this code\n\n\t\t} catch {\n\n\t\t\t # catch errors; execute this code\n\n\t\t} # end try/catch\n\n\t} # end END block\n\n} # end function Verb-Noun'
'Switch':
'prefix': 'switch'
'body': 'switch (\$${1:x})\n{\n\t"value1" {}\n\t{\$_ -in "A","B","C"} {}\n\t"value3" {}\n\tDefault {}\n}'