summaryrefslogtreecommitdiff
path: root/chip
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2019-09-02 21:43:27 -0700
committerBen Sima <ben@bsima.me>2019-09-02 21:45:02 -0700
commit481fa104753d51de9df060ff77ed68790c774955 (patch)
tree0031ea7bd8c49764bff2b9c0162b31c1c4d7a48d /chip
parent9af1370c102ff2873d8270a10c41cd7e87ecbfe1 (diff)
[chip/make] add a 'tidy' command
Diffstat (limited to 'chip')
-rwxr-xr-xchip/make13
1 files changed, 10 insertions, 3 deletions
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] <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 ω