3 ms·
For Powershell, I made a few functions to automate the process. I have: * New-ModuleFile to create a new module file. * Insert-TextIntoFile gives a way to spe
by stephengillie 9y ago
For Powershell, I made a few functions to automate the process. I have:
* New-ModuleFile to create a new module file.
* Insert-TextIntoFile gives a way to specify New-Function, New-Parameter, and any other Powershell function or Cmdlet parenthetically, so adding a function to a module file is a one-liner. I use the alias "instxt".
* New-Function provides the function punctuation and my closing flags.
* New-FunctionStatement (alias NFS) helps lay out any conditional function, including placing punctuation (brackets) and closing flags.
- Instead of typing all the brackets and parenthesis and variable names, I can type "nfs if text -scriptblock '$text' -else '"No Text"'"
* New-Parameter helps you specify Parameters and their numerous variables, such as Type, Mandatory, Position in the arguments list, Validate-Set List, and From Pipeline.
- Pipeline is a Powershell way of chaining Foreach in an ad-hoc fashion.
* Get-History returns previous commands as objects; these go nicely into "instxt".
- A common workflow is to create the function in the "instxt" statement, and have New-Parameter and Get-History as arguments.
- This way, a previously-tested function can be dropped straight into a module as a new function, with parameters already set up. From there, the module can be simply reloaded, and that function used as any loaded function.
The agility this gives is almost indescribable, and I wish I had a better way to demonstrate. Suggestions?