From 481fa104753d51de9df060ff77ed68790c774955 Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Mon, 2 Sep 2019 21:43:27 -0700 Subject: [chip/make] add a 'tidy' command --- chip/make | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'chip/make') diff --git a/chip/make b/chip/make index b24b62e..da5fe97 100755 --- a/chip/make +++ b/chip/make @@ -49,6 +49,9 @@ main = do void $ addWatch inotify [Modify] (pack arg) (const notify) forever $ wait >> bild app >> say "waiting..." Make -> bild app + Tidy -> do + callCommand "rm -rf bild/*" + say "made: tidy" bild :: App -> IO () bild app = do @@ -63,17 +66,21 @@ say = putStrLn nop :: SomeException -> IO () nop _ = pure () -data Action = Make | Rise + +data Action = Make | Rise | Tidy parseArgs :: [String] -> (App, Action) -parseArgs [] = errorWithoutStackTrace "usage: chip/make [make|rise] " +parseArgs [] = errorWithoutStackTrace "usage: chip/make [make|rise|tidy] " parseArgs (act:name:_) = ( App (lowercase name) (capitalize name) , case lowercase act of "rise" -> Rise + "tidy" -> Tidy _ -> Make ) -parseArgs (name:_) = (App (lowercase name) (capitalize name), Make) +parseArgs (name:_) = case name of + "tidy" -> (App (lowercase "") (capitalize ""), Tidy) + _ -> (App (lowercase name) (capitalize name), Make) capitalize, lowercase :: String -> String capitalize (α:ω) = Char.toUpper α : map Char.toLower ω -- cgit v1.2.3