-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCreate.ps1
33 lines (29 loc) · 821 Bytes
/
Create.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
if($args.Count -le 1) {
Write-Host "Usage: ./Create.ps1 <year> <day>"
return
}
$year=$args[0]
$day=$args[1]
if(-not (Test-Path -Path "$year")) {
Write-Host "Year $year does not exist yet."
if($args.Count -ge 3 -and $args[2] -eq "force") {
Write-Host "...but force flag was found. Creating!"
mkdir "$year"
} else {
return
}
}
if(Test-Path "$year\day$day") {
Write-Host "$year\day$day project already exists!"
return
}
Set-Location "$year"
Write-Host "Creating day$day cargo --bin project..."
cargo new --bin ("day$day")
Set-Location ..
Write-Host "Writing template to main.rs"
Get-Content "template.rs" > "$year\day$day\src\main.rs"
Set-Location "$year\day$day"
Write-Host "Adding dependency to aoc in Cargo.toml..."
cargo add --path ../../aoc
Write-Host "Done."