Skip to content
Browse files

add command to change current directory

  • Loading branch information...
1 parent 7308d26 commit 75e01411a2192d893319491c75f7c79ba9da6ccf @hannesm hannesm committed Mar 23, 2013
Showing with 6 additions and 0 deletions.
  1. +1 −0 src/Idris/AbsSyntaxTree.hs
  2. +1 −0 src/Idris/Help.hs
  3. +3 −0 src/Idris/REPL.hs
  4. +1 −0 src/Idris/REPLParser.hs
View
1 src/Idris/AbsSyntaxTree.hs
@@ -167,6 +167,7 @@ data Command = Quit
| TotCheck Name
| Reload
| Load FilePath
+ | ChangeDirectory FilePath
| ModImport String
| Edit
| Compile Target String
View
1 src/Idris/Help.hs
@@ -28,6 +28,7 @@ help =
([":total"], NameArg, "Check the totality of a name"),
([":r",":reload"], NoArg, "Reload current file"),
([":l",":load"], FileArg, "Load a new file"),
+ ([":cd"], FileArg, "Change working directory"),
([":m",":module"], ModuleArg, "Import an extra module"), -- NOTE: dragons
([":e",":edit"], NoArg, "Edit current file using $EDITOR or $VISUAL"),
([":m",":metavars"], MetaVarArg, "Show remaining proof obligations (metavariables)"),
View
3 src/Idris/REPL.hs
@@ -179,6 +179,9 @@ insertScript prf (x : xs) = x : insertScript prf xs
process :: FilePath -> Command -> Idris ()
process fn Help = iputStrLn displayHelp
+process fn (ChangeDirectory f)
+ = do liftIO $ setCurrentDirectory f
+ return ()
process fn (Eval t)
= do (tm, ty) <- elabVal toplevel False t
ctxt <- getContext
View
1 src/Idris/REPLParser.hs
@@ -45,6 +45,7 @@ pCmd = try (do cmd ["q", "quit"]; eof; return Quit)
<|> try (do cmd ["showproof"]; n <- pName; eof; return (ShowProof n))
<|> try (do cmd ["log"]; i <- natural; eof; return (LogLvl (fromIntegral i)))
<|> try (do cmd ["l", "load"]; f <- getInput; return (Load f))
+ <|> try (do cmd ["cd"]; f <- getInput; return (ChangeDirectory f))
<|> try (do cmd ["spec"]; t <- pFullExpr defaultSyntax; return (Spec t))
<|> try (do cmd ["hnf"]; t <- pFullExpr defaultSyntax; return (HNF t))
<|> try (do cmd ["doc"]; n <- pfName; eof; return (DocStr n))

0 comments on commit 75e0141

Please sign in to comment.
Something went wrong with that request. Please try again.