Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Param(
- # Path to the repo containing TODO-annotated files
- [Parameter(Mandatory)]
- [ValidateScript({Test-Path $_ -PathType Container})]
- [string]$RepoRoot
- )
- & {
- enum Priority {
- Low = 3
- Medium = 2
- High = 1
- }
- class ToDo {
- [string] $FilePath
- [Nullable[Priority]] $Priority
- [int] $Line
- [string] $Task
- }
- Push-Location $RepoRoot
- $files = Get-ChildItem . -File -Recurse `
- | % FullName `
- | ? {$_ -ne $PSCommandPath} `
- | Resolve-Path -Relative
- Pop-Location
- foreach ($file in $files) {
- $lines = Get-Content $file
- foreach ($i in 1..$lines.Count) {
- if ($lines[$i] -match "TODO: \(([^)]+)\) (.*)$") {
- # parse prioritized ToDo
- [ToDo]@{
- FilePath = $file
- Priority = $Matches[1]
- Line = $i + 1
- Task = $Matches[2]
- }
- } elseif ($lines[$i] -match "TODO: (.*)$") {
- # parse unprioritized ToDo
- [ToDo]@{
- FilePath = $file
- Priority = $null
- Line = $i + 1 # line numbers are 1-indexed
- Task = $Matches[1]
- }
- }
- }
- }
- } | Sort Priority, FilePath, Line
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement