Skip to content

Commit e3835b0

Browse files
authored
update usage information and add -a/-add option (#129)
1 parent 111c849 commit e3835b0

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

generators/GenerateTestFile.lean

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,14 @@ def fetchConfiglet : IO Unit := do
2727
cmd := "bin/fetch-configlet"
2828
}
2929

30-
def addPracticeExercise (exercise : String) : IO Unit := do
30+
def addPracticeExercise (exercise : String) (as : List String) : IO Unit := do
31+
let args := match as with
32+
| [] => #[exercise]
33+
| a :: [] => #["-a", a, exercise]
34+
| a :: d :: _ => #["-a", a, "-d", d, exercise]
3135
let child ← IO.Process.spawn {
3236
cmd := "bin/add-practice-exercise",
33-
args := #[exercise]
37+
args := args
3438
stdin := .inherit
3539
stdout := .inherit
3640
stderr := .inherit
@@ -163,14 +167,21 @@ def getIncludes (toml : String) : TreeMap String String :=
163167

164168
def showUsage : IO Unit :=
165169
let usageMsg := s!"Usage is:
166-
lake exe generator [Options] <exercise-slug>
170+
lake exe generator [Options] <exercise-slug> [Extra-Options]
167171
168172
Options:
169173
-s / --stub :
170174
Generates a stub Generator for the exercise in ./generators/Generator/Generator/
171175
172176
-g / --generate :
173-
Generates a test file for the exercise in ./exercises/practice/<exercise-slug>/"
177+
Generates a test file for the exercise in ./exercises/practice/<exercise-slug>/
178+
179+
-a / --add :
180+
Adds a practice exercise and then generates a test file, if there is a Generator for it.
181+
Other than the exercise slug, the author and the difficulty of the new exercise may be passed as extra options.
182+
183+
-r / --regenerate :
184+
Regenerates all test files with a Generator, syncing all docs and test data with canonical-data."
174185
IO.println usageMsg
175186

176187
def generateTestFile (exercise : String) : IO Unit := do
@@ -297,9 +308,12 @@ end {pascalExercise}Generator
297308
def main (args : List String) : IO Unit := do
298309
setDirectory
299310
match args with
311+
| "-a" :: exercise :: as
312+
| "--add" :: exercise :: as =>
313+
addPracticeExercise exercise as
314+
generateTestFile exercise.trim
300315
| "-g" :: exercise :: _
301316
| "--generate" :: exercise :: _ =>
302-
addPracticeExercise exercise
303317
generateTestFile exercise.trim
304318
| "-s" :: exercise :: _
305319
| "--stub" :: exercise :: _ =>

0 commit comments

Comments
 (0)