@@ -8,6 +8,7 @@ module Main (main) where
9import Data.Traversable (for)
9import Data.Traversable (for)
10import Data.Version (showVersion)
10import Data.Version (showVersion)
11+import Data.Monoid ((<>))
12import Control.Applicative
13import Control.Applicative
13import Control.Monad
14import Control.Monad
@@ -24,7 +25,8 @@ import System.Directory (createDirectoryIfMissing)
25import Language.PureScript.Bundle
26import Language.PureScript.Bundle
27−import Options.Applicative as Opts
28+import Options.Applicative (Parser, ParseError (..))
29+import qualified Options.Applicative as Opts
29import qualified Paths_purescript as Paths
31import qualified Paths_purescript as Paths
@@ -64,41 +66,41 @@ options = Options <$> some inputFile
64 <*> namespace
66 <*> namespace
66 inputFile :: Parser FilePath
68 inputFile :: Parser FilePath
67− inputFile = strArgument $
69+ inputFile = Opts.strArgument $
68− metavar "FILE"
70+ Opts.metavar "FILE"
69− <> help "The input .js file(s)"
71+ <> Opts.help "The input .js file(s)"
71 outputFile :: Parser FilePath
73 outputFile :: Parser FilePath
72− outputFile = strOption $
74+ outputFile = Opts.strOption $
73− short 'o'
75+ Opts.short 'o'
74− <> long "output"
76+ <> Opts.long "output"
75− <> help "The output .js file"
77+ <> Opts.help "The output .js file"
77 entryPoint :: Parser String
79 entryPoint :: Parser String
78− entryPoint = strOption $
80+ entryPoint = Opts.strOption $
79− short 'm'
81+ Opts.short 'm'
80− <> long "module"
82+ <> Opts.long "module"
81− <> help "Entry point module name(s). All code which is not a transitive dependency of an entry point module will be removed."
83+ <> Opts.help "Entry point module name(s). All code which is not a transitive dependency of an entry point module will be removed."
83 mainModule :: Parser String
85 mainModule :: Parser String
84− mainModule = strOption $
86+ mainModule = Opts.strOption $
85− long "main"
87+ Opts.long "main"
86− <> help "Generate code to run the main method in the specified module."
88+ <> Opts.help "Generate code to run the main method in the specified module."
88 namespace :: Parser String
90 namespace :: Parser String
89− namespace = strOption $
91+ namespace = Opts.strOption $
90− short 'n'
92+ Opts.short 'n'
91− <> long "namespace"
93+ <> Opts.long "namespace"
92 <> Opts.value "PS"
94 <> Opts.value "PS"
93− <> showDefault
95+ <> Opts.showDefault
94− <> help "Specify the namespace that PureScript modules will be exported to when running in the browser."
96+ <> Opts.help "Specify the namespace that PureScript modules will be exported to when running in the browser."
96-- | Make it go.
98-- | Make it go.
97main :: IO ()
99main :: IO ()
99 hSetEncoding stdout utf8
101 hSetEncoding stdout utf8
100 hSetEncoding stderr utf8
102 hSetEncoding stderr utf8
101− opts <- execParser (info (version <*> helper <*> options) infoModList)
103+ opts <- Opts.execParser (Opts.info (version <*> Opts.helper <*> options) infoModList)
102 output <- runExceptT (app opts)
104 output <- runExceptT (app opts)
103 case output of
105 case output of
104 Left err -> do
106 Left err -> do
@@ -111,9 +113,10 @@ main = do
111 writeFile outputFile js
113 writeFile outputFile js
112 Nothing -> putStrLn js
114 Nothing -> putStrLn js
114− infoModList = fullDesc <> headerInfo <> footerInfo
116+ infoModList = Opts.fullDesc <> headerInfo <> footerInfo
115− headerInfo = header "psc-bundle - Bundles compiled PureScript modules for the browser"
117+ headerInfo = Opts.header "psc-bundle - Bundles compiled PureScript modules for the browser"
116− footerInfo = footer $ "psc-bundle " ++ showVersion Paths.version
118+ footerInfo = Opts.footer $ "psc-bundle " ++ showVersion Paths.version
118 version :: Parser (a -> a)
120 version :: Parser (a -> a)
119− version = abortOption (InfoMsg (showVersion Paths.version)) $ long "version" <> help "Show the version number" <> hidden
121+ version = Opts.abortOption (InfoMsg (showVersion Paths.version)) $
122+ Opts.long "version" <> Opts.help "Show the version number" <> Opts.hidden