2020-09-07 22:55:13 +03:00
|
|
|
module Main where
|
|
|
|
|
|
|
|
import System.Environment
|
2020-10-29 15:15:13 +03:00
|
|
|
import Paths_waspc (version)
|
|
|
|
import Data.Version (showVersion)
|
2020-09-07 22:55:13 +03:00
|
|
|
|
|
|
|
import Command (runCommand)
|
2020-11-04 17:26:35 +03:00
|
|
|
import Command.Db (runDbCommand, studio)
|
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-10-29 15:15:13 +03:00
|
|
|
["version"] -> printVersion
|
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-10-29 15:15:13 +03:00
|
|
|
, " version"
|
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-10-29 15:15:13 +03:00
|
|
|
, " wasp db migrate-save \"init\""
|
|
|
|
, ""
|
|
|
|
, "Documentation is available at https://wasp-lang.dev/docs ."
|
2020-09-07 22:55:13 +03:00
|
|
|
]
|
|
|
|
|
2020-10-29 15:15:13 +03:00
|
|
|
printVersion :: IO ()
|
|
|
|
printVersion = putStrLn $ showVersion version
|
|
|
|
|
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-11-04 17:26:35 +03:00
|
|
|
["studio"] -> runDbCommand studio
|
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"
|
2020-11-04 17:26:35 +03:00
|
|
|
, " studio"
|
2020-09-18 17:14:14 +03:00
|
|
|
, ""
|
|
|
|
, "Examples:"
|
|
|
|
, " wasp db migrate-save \"Added description field.\""
|
|
|
|
, " wasp db migrate-up"
|
|
|
|
]
|