Skip to content
/ bob Public

PowerShell module builder

Notifications You must be signed in to change notification settings

cdhunt/bob

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bob

This project is an exploration of Software Design Patterns in PowerShell. Currently, the goal isn't to produce a usable module, but to test out some ideas of how to put PowerShell modules together. By building a module on top of PowerShell classes utilizing the Strategy pattern, we should be able to build a module that is easier to maintain and plug in additional functionality without changes to the core code.

We can use multiple forms of invocation depending on preference and context.

# PS Classes w/Fluent API
PS> [Job]::New('src', 'dst').
>>         AddStage([Clean]::New()).
>>         AddStage([Copy]::New()).
>>         AddStage([Test]::New()) | Select stages

Stages
------
{Clean, Copy, Test}

# Cmdlet Pipeline
PS> New-BuildJob src dst | Add-StageClean | Add-StageCopy | Add-StageTest | Select stages

Stages
------
{Clean, Copy, Test}


# Cmdlet Pipeline w/ Generic Cmdlet
PS> New-BuildJob src dst | Add-StageClean | Add-StageCopy | Add-BuildStage -Stage ([Test]::New()) | Select stages

Stages
------
{Clean, Copy, Test}


# DSL
BuildJob src dst {
    CleanStg
    CopyStg
    TestStg
} | Select stages

Stages
------
{Clean, Copy, Test}

# YAML Config
PS> New-BuildFromYaml .\build.yaml | Select stages

Stages
------
{Clean, Copy, Test}

⚠️ Please don't pay much attention to the names of things. This is not meant to be an example of a well-formed module. You probably won't win any scripting games by copying the structure of this module.