Naming convention for Improved module and cmdlets

This topic contains 4 replies, has 4 voices, and was last updated by  Luc FULLENWARTH 2 weeks, 1 day ago.

  • Author
    Posts
  • #83438

    Luc FULLENWARTH
    Participant

    I can find guidelines about the naming convention for new cmdlets and new modules.
    https://msdn.microsoft.com/en-us/library/ms714657(v=vs.85).aspx

    But what about an improved cmdlet of an existing module.
    For example, let's say I want to improve the Get-SmbShare cmdlet from the SmbShare module by adding a new parameter to the cmdlet.
    How could I name my module?

    • SmbShare2
    • SmbShareExtended
    • SmbShareImproved
    • ...

    Same question for the cmdlet inside the module. How could I name it?
    I've seen for example a Get-ChildItem2 cmdlet.

    I couldn't find any official guidelines about that...

  • #83440

    Olaf Soyk
    Participant

    If you have a little time left you could watch this video ... the relevant part is in the last quarter if I remember right ... have fun!

    https://www.youtube.com/watch?v=D15vh-ryJGk

    I guess they called it proxy cmdlet or cmdlet proxy or something like this.

  • #83446

    Joe Acosta
    Participant

    I've used two approaches that are my own home-spun-ideas (certainly not guidelines):

    1: Append an M to the command for improved, akin to vim for vi in Unix. So Verb-NounM
    2: I've "broken the rules" for one lone command which has really no impact as I'm the only person that uses the function. It's my exception to the Verb-Noun rule. Explained:

    I used to alias cvi to Connect-VIServer. One day I elected to add the functionality of putting the VIServer I'm connect{ing,ed} to in the title bar as I maintain several Virtual Centers. Yes, I prefer to set PowerCLI to Single VIServer Mode and have a separate window for each. Or, if I disconnect from one and connect to another, the correct Virtual Center is reflected in the title bar. Crude but effective (per my buddy Darth).

    Ergo I made the function below to a) add functionality to the command and b) maintain my "alias". I know this isn't textbook and if someone has a better idea, I'm all for it.

    function cvi
    {
    Connect-VIServer -Server $args[0]
    $host.ui.RawUI.WindowTitle = $global:DefaultVIServer
    }

  • #83464

    Jeremy Murrah
    Participant

    My favorite method for customized cmdlets is to add a prefix to the noun. Like your initials, or a company stock symbol, or something like that. So Get-LFSMBShare and Set-LFSMBShare. The benefit to that method is in command discovery. Get-LF will autocomplete through all of your customized cmdlets. Seems easier to find too when you're doing things like get-command, etc.

  • #83639

    Luc FULLENWARTH
    Participant

    Thanks all for your suggestions! 🙂

You must be logged in to reply to this topic.