-
Notifications
You must be signed in to change notification settings - Fork 0
/
new-day-project.ps1
52 lines (47 loc) · 1.06 KB
/
new-day-project.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
[CmdletBinding()]
param(
[Parameter(Mandatory = $true, HelpMessage = "In 'dayXX' or 'XX' format, later reformatted to 'DayXX'")]
[string]$day,
[Parameter(ValueFromRemainingArguments = $true)]
[string]$dayTitle
)
$year = 2023
if ($day -notmatch '^(day)?(\d\d?)$')
{
Write-Error "Invalid day number"
exit 1
}
$day = [int]$Matches[2]
if ($day -lt 1 -or $day -gt 25)
{
Write-Error "Invalid day number, available days are 1 to 25 (got $day)"
exit 1
}
$day = '{0:d2}' -f [int]$day
$day = "Day$day"
if (-not $dayTitle)
{
$providedTitle = Read-Host "Title (leave empty to skip)"
if ($providedTitle)
{
$dayTitle = $providedTitle
}
}
if (-not $dayTitle)
{
dotnet new aocday --year $year -o "$day"
dotnet sln add ".\$day\"
cd Tests
dotnet add reference "..\$day"
cd ..
}
else
{
dotnet new aocday --year $year -o "$day" --title "$dayTitle"
$folderName = "$day - $dayTitle"
Rename-Item "$day" "$folderName"
dotnet sln add ".\$folderName\"
cd Tests
dotnet add reference "..\$folderName"
cd ..
}