@@ -252,6 +252,13 @@ def runCommand (s : Command) : M IO (CommandResponse ⊕ Error) := do
252
252
tactics
253
253
infotree }
254
254
255
+ def processFile (s : File) : M IO (CommandResponse ⊕ Error) := do
256
+ try
257
+ let cmd ← IO.FS.readFile s.path
258
+ runCommand { s with env := none, cmd }
259
+ catch e =>
260
+ pure <| .inr ⟨e.toString⟩
261
+
255
262
/--
256
263
Run a single tactic, returning the id of the new proof statement, and the new goals.
257
264
-/
@@ -286,6 +293,7 @@ instance [ToJson α] [ToJson β] : ToJson (α ⊕ β) where
286
293
/-- Commands accepted by the REPL. -/
287
294
inductive Input
288
295
| command : REPL.Command → Input
296
+ | file : REPL.File → Input
289
297
| proofStep : REPL.ProofStep → Input
290
298
| pickleEnvironment : REPL.PickleEnvironment → Input
291
299
| unpickleEnvironment : REPL.UnpickleEnvironment → Input
@@ -310,6 +318,8 @@ def parse (query : String) : IO Input := do
310
318
| .ok (r : REPL.UnpickleProofState) => return .unpickleProofSnapshot r
311
319
| .error _ => match fromJson? j with
312
320
| .ok (r : REPL.Command) => return .command r
321
+ | .error _ => match fromJson? j with
322
+ | .ok (r : REPL.File) => return .file r
313
323
| .error e => throw <| IO.userError <| toString <| toJson <|
314
324
(⟨"Could not parse as a valid JSON command:\n " ++ e⟩ : Error)
315
325
@@ -323,6 +333,7 @@ where loop : M IO Unit := do
323
333
if query.startsWith "#" || query.startsWith "--" then loop else
324
334
IO.println <| toString <| ← match ← parse query with
325
335
| .command r => return toJson (← runCommand r)
336
+ | .file r => return toJson (← processFile r)
326
337
| .proofStep r => return toJson (← runProofStep r)
327
338
| .pickleEnvironment r => return toJson (← pickleCommandSnapshot r)
328
339
| .unpickleEnvironment r => return toJson (← unpickleCommandSnapshot r)
0 commit comments