Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

A teensy bit of cleanup.

  • Loading branch information...
commit ad66b2202d006a9089dff38c45f3048e6c1dff4b 1 parent aea2877
Luke Palmer authored
Showing with 15 additions and 7 deletions.
  1. +15 −7 udon-shell/Main.hs
22 udon-shell/Main.hs
View
@@ -1,9 +1,12 @@
+{-# LANGUAGE PatternGuards #-}
+
module Main where
import Prelude hiding (log)
import UdonShell.FST
import UdonShell.FSDB
import Udon.API
+import Data.List (intercalate)
import System.Environment
import Data.Maybe (fromJust)
import Control.Applicative
@@ -90,13 +93,18 @@ cmdGC [] = do
gcCollect [exp]
+commands = [ "init" --> cmdInit
+ , "let" --> cmdLet
+ , "ls" --> cmdLs
+ , "show" --> cmdShow
+ , "gc" --> cmdGC
+ ]
+ where
+ (-->) = (,)
+
main = do
args <- getArgs
case args of
- [] -> putStrLn "Commands: init, let, ls, show, gc"
- ("init":cmdargs) -> cmdInit cmdargs
- ("let":cmdargs) -> cmdLet cmdargs
- ("ls":cmdargs) -> cmdLs cmdargs
- ("show":cmdargs) -> cmdShow cmdargs
- ("gc":cmdargs) -> cmdGC cmdargs
- _ -> putStrLn "Unknown command"
+ [] -> hPutStrLn stderr $ "Commands: " ++ intercalate ", " (map fst commands)
+ (cmd:args) | Just f <- lookup cmd commands -> f args
+ | otherwise -> hPutStrLn stderr "Unknown command"
Please sign in to comment.
Something went wrong with that request. Please try again.