2020-09-07 22:55:13 +03:00
|
|
|
module Main where
|
|
|
|
|
|
|
|
import System.Environment
|
|
|
|
|
|
|
|
import Command (runCommand)
|
2020-10-20 12:02:00 +03:00
|
|
|
import Command.Db (runDbCommand)
|
2020-09-07 22:55:13 +03:00
|
|
|
import Command.CreateNewProject (createNewProject)
|
|
|
|
import Command.Start (start)
|
|
|
|
import Command.Clean (clean)
|
2020-09-19 17:11:09 +03:00
|
|
|
import Command.Compile (compile)
|
2020-09-18 17:14:14 +03:00
|
|
|
import Command.Db.Migrate (migrateSave, migrateUp)
|
2020-09-07 22:55:13 +03:00
|
|
|
|
|
|
|
|
|
|
|
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
|
2020-09-15 17:39:56 +03:00
|
|
|
("db":dbArgs) -> dbCli dbArgs
|
2020-09-07 22:55:13 +03:00
|
|
|
_ -> printUsage
|
|
|
|
|
|
|
|
printUsage :: IO ()
|
|
|
|
printUsage = putStrLn $ unlines
|
|
|
|
[ "Usage:"
|
|
|
|
, " wasp <command> [command-args]"
|
|
|
|
, ""
|
|
|
|
, "Commands:"
|
|
|
|
, " new <project-name>"
|
|
|
|
, " start"
|
|
|
|
, " clean"
|
2020-09-15 17:39:56 +03:00
|
|
|
, " db <commmand> [command-args]"
|
2020-09-07 22:55:13 +03:00
|
|
|
, ""
|
|
|
|
, "Examples:"
|
2020-10-15 19:17:40 +03:00
|
|
|
, " wasp new MyApp"
|
2020-09-07 22:55:13 +03:00
|
|
|
, " wasp start"
|
|
|
|
]
|
|
|
|
|
2020-09-15 17:39:56 +03:00
|
|
|
-- TODO(matija): maybe extract to a separate module, e.g. DbCli.hs?
|
|
|
|
dbCli :: [String] -> IO ()
|
|
|
|
dbCli args = case args of
|
2020-10-20 12:02:00 +03:00
|
|
|
["migrate-save", migrationName] -> runDbCommand $ migrateSave migrationName
|
|
|
|
["migrate-up"] -> runDbCommand migrateUp
|
2020-09-15 17:39:56 +03:00
|
|
|
_ -> printDbUsage
|
2020-09-07 22:55:13 +03:00
|
|
|
|
2020-09-15 17:39:56 +03:00
|
|
|
printDbUsage :: IO ()
|
2020-09-18 17:14:14 +03:00
|
|
|
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"
|
|
|
|
]
|