mirror of
https://github.com/wasp-lang/wasp.git
synced 2024-12-25 10:03:07 +03:00
Prettified CLI usage output.
This commit is contained in:
parent
e7669f3dc3
commit
e32bca9007
@ -6,6 +6,7 @@ import Control.Monad (void)
|
||||
import Data.Version (showVersion)
|
||||
import Paths_waspc (version)
|
||||
import System.Environment
|
||||
import Data.Char (isSpace)
|
||||
|
||||
import Command (runCommand)
|
||||
import Command.Build (build)
|
||||
@ -17,6 +18,7 @@ import Command.Db (runDbCommand, studio)
|
||||
import Command.Db.Migrate (migrateSave, migrateUp)
|
||||
import Command.Start (start)
|
||||
import qualified Command.Telemetry as Telemetry
|
||||
import qualified Util.Terminal as Term
|
||||
|
||||
|
||||
main :: IO ()
|
||||
@ -53,23 +55,26 @@ main = do
|
||||
|
||||
printUsage :: IO ()
|
||||
printUsage = putStrLn $ unlines
|
||||
[ "Usage:"
|
||||
, " wasp <command> [command-args]"
|
||||
, ""
|
||||
, "Commands:"
|
||||
, " new <project-name>"
|
||||
, " start"
|
||||
, " clean"
|
||||
, " db <commmand> [command-args]"
|
||||
, " build"
|
||||
, " version"
|
||||
, ""
|
||||
, "Examples:"
|
||||
, " wasp new MyApp"
|
||||
, " wasp start"
|
||||
, " wasp db migrate-save \"init\""
|
||||
, ""
|
||||
, "Documentation is available at https://wasp-lang.dev/docs ."
|
||||
[ title "USAGE"
|
||||
, " wasp <command> [command-args]"
|
||||
, ""
|
||||
, title "COMMANDS"
|
||||
, title " GENERAL"
|
||||
, cmd " new <project-name> Creates new Wasp project."
|
||||
, cmd " version Prints current version of CLI."
|
||||
, title " IN PROJECT"
|
||||
, cmd " start Runs Wasp app in development mode, watching for file changes."
|
||||
, cmd " db <db-cmd> [args] Executes a database command. Run 'wasp db' for more info."
|
||||
, cmd " clean Deletes all generated code and other cached artifacts. Wasp equivalent of 'have you tried closing and opening it again?'."
|
||||
, cmd " build Generates full web app code, ready for deployment. Use when deploying or ejecting."
|
||||
, ""
|
||||
, title "EXAMPLES"
|
||||
, " wasp new MyApp"
|
||||
, " wasp start"
|
||||
, " wasp db migrate-save \"init\""
|
||||
, ""
|
||||
, Term.applyStyles [Term.Green] "Docs:" ++ " https://wasp-lang.dev/docs"
|
||||
, Term.applyStyles [Term.Magenta] "Discord (chat):" ++ " https://discord.gg/rzdnErX"
|
||||
]
|
||||
|
||||
printVersion :: IO ()
|
||||
@ -85,15 +90,27 @@ dbCli args = case args of
|
||||
|
||||
printDbUsage :: IO ()
|
||||
printDbUsage = putStrLn $ unlines
|
||||
[ "Usage:"
|
||||
, " wasp db <command> [command-args]"
|
||||
, ""
|
||||
, "Commands:"
|
||||
, " migrate-save <migration-name>"
|
||||
, " migrate-up"
|
||||
, " studio"
|
||||
, ""
|
||||
, "Examples:"
|
||||
, " wasp db migrate-save \"Added description field.\""
|
||||
, " wasp db migrate-up"
|
||||
[ title "USAGE"
|
||||
, " wasp db <command> [command-args]"
|
||||
, ""
|
||||
, title "COMMANDS"
|
||||
, cmd " migrate-save <migration-name> Saves a migration for updating to current schema."
|
||||
, cmd " migrate-up Applies all migrations, updating your db to the current schema."
|
||||
, cmd " studio GUI for inspecting your database."
|
||||
, ""
|
||||
, title "EXAMPLES"
|
||||
, " wasp db migrate-save \"Added description field.\""
|
||||
, " wasp db migrate-up"
|
||||
]
|
||||
|
||||
title :: String -> String
|
||||
title = Term.applyStyles [Term.Bold]
|
||||
|
||||
cmd :: String -> String
|
||||
cmd = mapFirstWord (Term.applyStyles [Term.Yellow, Term.Bold])
|
||||
|
||||
mapFirstWord :: (String -> String) -> String -> String
|
||||
mapFirstWord f s = beforeFirstWord ++ f firstWord ++ afterFirstWord
|
||||
where
|
||||
(beforeFirstWord, firstWordAndAfter) = span isSpace s
|
||||
(firstWord, afterFirstWord) = break isSpace firstWordAndAfter
|
||||
|
Loading…
Reference in New Issue
Block a user