diff --git a/app/Main.hs b/app/Main.hs index 110e2c5..1c939fa 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -159,11 +159,15 @@ world0 = World { main :: IO () main = do args <- getArgs - let name = case args of x:_ -> x; [] -> "" - bracket (mkVty =<< userConfig) shutdown \vty -> - do - loop vty (pure (pickWorld name)) - pure () + case args of + x:_ | Just w <- Map.lookup x worldList -> + bracket (mkVty =<< userConfig) shutdown \vty -> + loop vty (pure w) + _ -> + do putStrLn "Usage: parabox " + putStrLn "" + putStrLn "Available worlds:" + mapM_ putStrLn (Map.keys worldList) loop :: Vty -> NonEmpty World -> IO () loop vty (world :| history) = @@ -184,13 +188,16 @@ loop vty (world :| history) = _ -> loop vty (world :| history) _ -> loop vty (world :| history) -pickWorld :: String -> World -pickWorld "world0" = world0 -pickWorld "small" = smallWorld -pickWorld "center8" = center8 -pickWorld "center13" = center13 -pickWorld "clone11" = clone11 -pickWorld _ = transfer14 + +worldList :: Map.Map String World +worldList = Map.fromList + [ ("world0", world0) + , ("small", smallWorld) + , ("center8", center8) + , ("center13", center13) + , ("clone11", clone11) + , ("transfer14", transfer14) + ] smallWorld :: World smallWorld =