wasp/waspc/cli/Main.hs

61 lines
1.5 KiB
Haskell
Raw Normal View History

module Main where
import System.Environment
import Command (runCommand)
import Command.Db (runDbCommand)
import Command.CreateNewProject (createNewProject)
import Command.Start (start)
import Command.Clean (clean)
2020-09-19 17:11:09 +03:00
import Command.Compile (compile)
import Command.Db.Migrate (migrateSave, migrateUp)
main :: IO ()
main = do
args <- getArgs
case args of
["new", projectName] -> runCommand $ createNewProject projectName
["start"] -> runCommand start
["clean"] -> runCommand clean
2020-09-19 17:11:09 +03:00
["compile"] -> runCommand compile
("db":dbArgs) -> dbCli dbArgs
_ -> printUsage
printUsage :: IO ()
printUsage = putStrLn $ unlines
[ "Usage:"
, " wasp <command> [command-args]"
, ""
, "Commands:"
, " new <project-name>"
, " start"
, " clean"
, " db <commmand> [command-args]"
, ""
, "Examples:"
, " wasp new MyApp"
, " wasp start"
]
-- TODO(matija): maybe extract to a separate module, e.g. DbCli.hs?
dbCli :: [String] -> IO ()
dbCli args = case args of
["migrate-save", migrationName] -> runDbCommand $ migrateSave migrationName
["migrate-up"] -> runDbCommand migrateUp
_ -> printDbUsage
printDbUsage :: IO ()
printDbUsage = putStrLn $ unlines
[ "Usage:"
, " wasp db <command> [command-args]"
, ""
, "Commands:"
, " migrate-save <migration-name>"
, " migrate-up"
, ""
, "Examples:"
, " wasp db migrate-save \"Added description field.\""
, " wasp db migrate-up"
]