Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. Param(
  2. # Path to the repo containing TODO-annotated files
  3. [Parameter(Mandatory)]
  4. [ValidateScript({Test-Path $_ -PathType Container})]
  5. [string]$RepoRoot
  6. )
  7.  
  8. & {
  9. enum Priority {
  10. Low = 3
  11. Medium = 2
  12. High = 1
  13. }
  14.  
  15. class ToDo {
  16. [string] $FilePath
  17. [Nullable[Priority]] $Priority
  18. [int] $Line
  19. [string] $Task
  20. }
  21.  
  22. Push-Location $RepoRoot
  23. $files = Get-ChildItem . -File -Recurse `
  24. | % FullName `
  25. | ? {$_ -ne $PSCommandPath} `
  26. | Resolve-Path -Relative
  27. Pop-Location
  28.  
  29. foreach ($file in $files) {
  30. $lines = Get-Content $file
  31. foreach ($i in 1..$lines.Count) {
  32. if ($lines[$i] -match "TODO: \(([^)]+)\) (.*)$") {
  33. # parse prioritized ToDo
  34. [ToDo]@{
  35. FilePath = $file
  36. Priority = $Matches[1]
  37. Line = $i + 1
  38. Task = $Matches[2]
  39. }
  40. } elseif ($lines[$i] -match "TODO: (.*)$") {
  41. # parse unprioritized ToDo
  42. [ToDo]@{
  43. FilePath = $file
  44. Priority = $null
  45. Line = $i + 1 # line numbers are 1-indexed
  46. Task = $Matches[1]
  47. }
  48. }
  49. }
  50. }
  51. } | Sort Priority, FilePath, Line
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement