-
Notifications
You must be signed in to change notification settings - Fork 0
/
new-day.fsx
42 lines (30 loc) · 882 Bytes
/
new-day.fsx
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
open System.IO
let args = fsi.CommandLineArgs
if args.Length = 1 then
printfn $"Usage: {args[0]} <day number>"
exit 1
let num = int args[1]
let codeTemplate = $"module AdventOfCode.Day{num}
let parseInput input =
0
"
let testTemplate = $"""module AdventOfCode.TestsDay{num}
open NUnit.Framework
open AdventOfCode
open System.IO
open FsUnit
let sampleInput = ""
let realInput = "day{num}.input" |> File.ReadAllText
[<Test>]
let parseInput() =
let result = Day{num}.parseInput sampleInput
result |> should equal 0
"""
let codeProj = "AdventOfCode"
let testProj = "AdventOfCode.Tests"
let codeFile = $"Day{num}.fs"
let testFile = $"Day{num}Test.fs"
let inputFile = $"day{num}.input"
File.WriteAllText ($"{codeProj}/{codeFile}", codeTemplate)
File.WriteAllText ($"{testProj}/{inputFile}", "")
File.WriteAllText ($"{testProj}/{testFile}", testTemplate)