Thursday, May 24, 2007

Microsoft's Command Line Standard

This PowerShell team blog entry has a link to a useful document that describes the Command Line Standard developers must use to create consistent command line commands (a lot of command here!).

I think the document is useful for the common PowerShell scripter as well. Especially Appendix A – Standardized Verb Sets and Verb Names and Appendix B – Standardized Parameters should be used when you are naming your own functions and scripts.

Here's another small quote from the document that is also useful to remember

Commands should use their product or feature name (or abbreviation) to prefix their noun. Many teams will have similar noun names. For instance, many
database teams might create the command “new-table”. To avoid collisions, it is best to prefix common noun names with the product or feature name. e.g. “New-SqlTable

So my function should not be called e.g. Sharepoint-Get-Item but Get-SharepointItem and the server argument should be called -ComputerName and nothing else.

Keeping consistent naming is important as soon as you start to share the scripts. The users using the scripts will learn to use them much faster.

PS. The - by far - best way of managing objects is to have a provider giving you a file system like access. In this way commands like Get-SharepointItem are simply unnecessary as Get-Item SharepointDrive:ItemName would do the job.

No comments: