forked from purescript/purescript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.hs
More file actions
64 lines (59 loc) · 2.46 KB
/
Main.hs
File metadata and controls
64 lines (59 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TupleSections #-}
module Main where
import qualified Command.Bundle as Bundle
import qualified Command.Compile as Compile
import qualified Command.Docs as Docs
import qualified Command.Hierarchy as Hierarchy
import qualified Command.Ide as Ide
import qualified Command.Publish as Publish
import qualified Command.REPL as REPL
import Data.Foldable (fold)
import Data.Monoid ((<>))
import Data.Version (showVersion)
import qualified Options.Applicative as Opts
import qualified Paths_purescript as Paths
import qualified System.IO as IO
main :: IO ()
main = do
IO.hSetEncoding IO.stdout IO.utf8
IO.hSetEncoding IO.stderr IO.utf8
cmd <- Opts.execParser opts
cmd
where
opts = Opts.info (versionInfo <*> Opts.helper <*> commands) infoModList
infoModList = Opts.fullDesc <> headerInfo <> footerInfo
headerInfo = Opts.progDesc "The PureScript compiler and tools"
footerInfo = Opts.footer $ "psc " ++ showVersion Paths.version
versionInfo :: Opts.Parser (a -> a)
versionInfo = Opts.abortOption (Opts.InfoMsg (showVersion Paths.version)) $
Opts.long "version" <> Opts.help "Show the version number" <> Opts.hidden
commands :: Opts.Parser (IO ())
commands =
(Opts.subparser . fold)
[ Opts.command "bundle"
(Opts.info Bundle.command
(Opts.progDesc "Bundle compiled PureScript modules for the browser"))
, Opts.command "compile"
(Opts.info Compile.command
(Opts.progDesc "Compile PureScript source files"))
, Opts.command "docs"
(Opts.info Docs.command
(Opts.progDesc "Generate Markdown documentation from PureScript source files" <> Docs.infoModList))
, Opts.command "hierarchy"
(Opts.info Hierarchy.command
(Opts.progDesc "Generate a GraphViz directed graph of PureScript type classes"))
, Opts.command "ide"
(Opts.info Ide.command
(Opts.progDesc "Start an IDE server process"))
, Opts.command "publish"
(Opts.info Publish.command
(Opts.progDesc "Generates documentation packages for upload to Pursuit"))
, Opts.command "repl"
(Opts.info REPL.command
(Opts.progDesc "Enter the interactive mode (PSCi)"))
]