-
Notifications
You must be signed in to change notification settings - Fork 1
/
commitment-allocation.ps1
71 lines (61 loc) · 1.65 KB
/
commitment-allocation.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
64
65
66
67
68
69
70
71
# DESCRIPTION
# area
# activity
# hrs per day, wk, mo
param (
[ValidateScript({Test-Path $_})]
[Parameter(Position = 0)]
$ActivitiesFile = "activities.json"
)
#Test-Path -Path $ActivitiesFile
try {
$Activities = loadActivities -ActivitiesFile $ActivitiesFile -Verbose
} catch {
$Activities = @()
}
# $Activity = @{
# Name = "Sleeping";
# HoursWeekly = 45.5;
# IsRestful = $false; # only conscious resting activities count
# }
# $Activities += $Activity
$HoursInAWeek = 168
$WorkRestRatio = 6/7 # 6:1
$Hours
# save activities
function saveActivities {
param (
$Activities = $ActivitiesObject,
$ActivitiesFile = $ActivitiesFile
)
ConvertTo-Json $Activities | Out-File $ActivitiesFile -Verbose
}
# load activities
function loadActivities {
param (
$ActivitiesFile = $ActivitiesFile
)
Write-Host "Loading file $ActivitiesFile..."
return ConvertFrom-Json $ActivitiesFile
}
# add activity
function addActivity {
param (
$Activities = $Activities
)
$Activity = @{}
$Activity.Name = Read-Host -Prompt "Name? "
$Activity.HoursWeekly = Read-Host -Prompt "HoursWeekly? "
$Activity.IsRestful = Read-Host -Prompt "Is this Restful? "
$Activities += $Activity
saveActivities -Activities $Activities
return $Activities
}
# edit activity
# display activities
$PercentAllocated = $Activities.HoursWeekly * 100 / $HoursInAWeek
$Margin = 100 - $PercentAllocated
$HoursRemaining = $HoursInAWeek - $Activities.HoursWeekly
Write-Host "$($Activities.Count) activites accounting for $PercentAllocated"
Write-Host "$HoursRemaining hours remaining ($Margin% margin)"
addActivity