-
Notifications
You must be signed in to change notification settings - Fork 0
/
Start-Pomodoro.ps1
63 lines (55 loc) · 1.7 KB
/
Start-Pomodoro.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
function Start-Pomodoro {
[CmdletBinding()]
param(
[Parameter(Position = 0)]
[ValidateNotNullOrEmpty()]
[datetime]
$EndDate = (Get-Date).AddMinutes(90),
[Parameter(ValueFromPipeline,
Position = 1)]
[ValidateNotNullOrEmpty()]
[string[]]
$Subjects,
[Parameter(Position = 2)]
[Switch]
$ShowBlocks
)
begin {
<#
foreach subject,
We create a "run" hash table,
output the start/end values.
and then run everything in the end block.
#>
$StartDate = Get-Date
<#
We have 30 minute blocks and each block contains a subject and a rest.
So each block is essentially 2.
#>
$TotalBlocks = (($EndDate - $StartDate).TotalMinutes / 30) * 2
[PSCustomObject]$DetailsTable = 1..$TotalBlocks |
ForEach-Object -Begin {
Write-Verbose -Message "[$((Get-Date).TimeOfDay)][$($MyInvocation.MyCommand)] Populating details table"
} -Process {
if (($_ % 2) -ne 0) {
@{Work = 25}
} else {
@{Rest = 5}
}
} -End {
Write-Verbose -Message "[$((Get-Date).TimeOfDay)][$($MyInvocation.MyCommand)] Populated details table"
}
}
process {
foreach ($Action in $DetailsTable) {
[PSCustomObject]@{
Timing = $Action.Values
Subject = $Action.Keys -as [String]
StartDate = $StartDate
EndDate = $EndDate
}
}
}
end {
}
}