Skip to content

Instantly share code, notes, and snippets.

View chriskuech's full-sized avatar

Chris Kuech chriskuech

  • Datum Source, ex MSFT
View GitHub Profile
... # previous param definition
& {
... # previous class and enum definitions
foreach ($file in $files) {
$lines = Get-Content $file
foreach ($i in 1..$lines.Count) {
if ($lines[$i] -match "TODO: \(([^)]+)\) (.*)$") {
# parse prioritized ToDo
Push-Location $RepoRoot
$files = Get-ChildItem . -File -Recurse `
| % FullName `
| ? {$_ -ne $PSCommandPath} `
| Resolve-Path -Relative
Pop-Location
TODO: \(([^)]+)\) (.*)$
TODO: (.*)$
TODO: (HIGH) Remove hard-coded secret
TODO: (LOW) Upgrade to LTS version
TODO: I think this can be cleaner
enum Priority {
Low = 3
Medium = 2
High = 1
}
class ToDo {
[string] $FilePath
[Nullable[Priority]] $Priority
[int] $Line
Param(
# Path to the repo containing TODO-annotated files
[Parameter(Mandatory)]
[ValidateScript({Test-Path $_ -PathType Container})]
[string]$RepoRoot
)
Method Lifecycle Name Date
------ --------- ---- ----
Test Start Resource 1 6/12/2019 12:00:25 PM
Test Stop Resource 1 6/12/2019 12:00:25 PM
Set Start Resource 1 6/12/2019 12:00:25 PM
Set Stop Resource 1 6/12/2019 12:00:26 PM
Validate Start Resource 1 6/12/2019 12:00:26 PM
Validate Stop Resource 1 6/12/2019 12:00:26 PM
Test Start Resource 2 6/12/2019 12:00:26 PM
Test Stop Resource 2 6/12/2019 12:00:26 PM
$requirements | Invoke-Requirement | Format-Table -AutoSize
enum Method {Test; Set; Validate}
enum Lifecycle {Start; Stop}
class RequirementEvent {
[Method] $Method
[Lifecycle] $Lifecycle
[string] $Name
[datetime] $Date = (Get-Date)
RequirementEvent($name, $method, $lifecycle) {
function Invoke-Requirement {
[CmdletBinding()]
Param(
[Parameter(Mandatory, ValueFromPipeline)]
[ValidateNotNullOrEmpty()]
[Requirement[]]$Requirement
)
process {
$result = &$_.Test