restructure agora-scripts modules

In order to allow reusing this code in the future, I've made it so that
Agora-specific code all lives in `Main`, and everything else lives in
`ScriptExport` or other non-Agora modules.
This commit is contained in:
Emily Martins 2022-06-23 19:54:34 +02:00
parent 7466901875
commit a5765a355d
10 changed files with 345 additions and 267 deletions

View file

@ -0,0 +1,39 @@
{- |
Module : ScriptExport.Options
Maintainer : emi@haskell.fyi
Description: Command line options for 'agora-scripts'.
Command line options for 'agora-scripts'.
-}
module ScriptExport.Options (Options (..), parseOptions) where
import Network.Wai.Handler.Warp qualified as Warp
import Options.Applicative ((<**>))
import Options.Applicative qualified as Opt
newtype Options = Options
{ port :: Warp.Port
}
deriving stock (Show, Eq)
opt :: Opt.Parser Options
opt =
Options
<$> Opt.option
Opt.auto
( Opt.long "port"
<> Opt.short 'p'
<> Opt.metavar "PORT"
<> Opt.value 3939
<> Opt.help "The path where the script configuration is."
)
parseOptions :: IO Options
parseOptions = Opt.execParser p
where
p =
Opt.info
(opt <**> Opt.helper)
( Opt.fullDesc
<> Opt.progDesc "Generate Agora scripts for off-chain use."
)