diff options
author | Ben Sima <ben@bsima.me> | 2019-09-02 21:43:27 -0700 |
---|---|---|
committer | Ben Sima <ben@bsima.me> | 2019-09-02 21:45:02 -0700 |
commit | 481fa104753d51de9df060ff77ed68790c774955 (patch) | |
tree | 0031ea7bd8c49764bff2b9c0162b31c1c4d7a48d /chip/make | |
parent | 9af1370c102ff2873d8270a10c41cd7e87ecbfe1 (diff) |
[chip/make] add a 'tidy' command
Diffstat (limited to 'chip/make')
-rwxr-xr-x | chip/make | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -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] <app>" +parseArgs [] = errorWithoutStackTrace "usage: chip/make [make|rise|tidy] <app>" 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 ω |