language-powershell
language-powershell copied to clipboard
Updated 'Function' Snippets
- Updated 'Function Cmdlet' snippet to include some best practices
- Moved comment based help inside the function, which makes it more compatible/easier to work with when converting/copy/pasting code into modules or other scripts
- Added additional detail in comment based help
- Added some spacing to the syntax
- Added .NET type names for parameters
- Added new 'Advanced Function Cmdlet' snippet
- This includes expanded support for try/catch blocks in each code section
I'm not a CoffeeScript expert; some of the formatting may need updated and/or other best practice followed.
Thanks for this! i'll be taking a look at it momentarily.
The test failures appear unrelated.
These are very nice and provide a lot of guidance, thanks!
i'd prefer that the function snippet be simpler. For just writing a function, i'm not sure the Begin
, Process
, and End
blocks are all necessary. Those seemed well covered in the advanced function snippet. Would you be interested in simplifying that snippet?
i think i'd prefer that there be another snippet to provide documentation generation (maybe we replace the current doc snippets with your stuff) so that users can choose to add it. Do you agree? Would you mind making that switch?
We could even make the Begin, Process, End, its own snippet too.
i'm not writing powershell for more than a couple scripts to build, test, and deploy NuGets so i'm very open to input.
i'll try to get those tests fixed! They aren't very helpful in their current state!
I'm glad you made all of those points; I was actually thinking, after I finished the mods in this PR, about adding a greater level of modularity and breaking out snippets for:
- Comment Based Help
- Advanced Function (just keep the one that I already created)
- Function (Simple)
- Take out the comment based help
- Only leave the
Process
block after the function declaration.- (it's considered a best practice to keep code in a
Process
block, at the very least, when writing functions. If you don't put code in aProcess
block, the PowerShell engine executes all of the code as if were running in theEnd
block, which can affect function execution/behavior, particularity when accepting pipeline input.)
- (it's considered a best practice to keep code in a
I have some ideas on how we can achieve that; I'll make some edits and commit the changes to this PR.
Yeah this sounds great. I'm excited to see it :)
On Nov 19, 2015, at 11:21 AM, Kevin Kirkpatrick [email protected] wrote:
I'm glad you made all of those points; I was actually thinking, after I finished the mods in this PR, about adding a greater level of modularity and breaking out snippets for:
Comment Based Help Advanced Function (just keep the one that I already created) Function (Simple) Take out the comment based help Only leave the Process block after the function declaration. (it's considered a best practice to keep code in a Process block, at the very least, when writing functions. If you don't put code in a Process block, the PowerShell engine executes all of the code as if were running in the End block, which can affect function execution/behavior, particularity when accepting pipeline input.) I have some ideas on how we can achieve that; I'll make some edits and commit the changes to this PR.
— Reply to this email directly or view it on GitHub.
If you merge in master, i think you may get the test fixes i tried to make as well.
Okay, cool; I'll update my remote branch before I commit.