moduleHbro.Boot(-- * Commandline optionsgetOptions,-- * Dynamic reconfigurationprintDyrePaths,recompile,-- * Boothbro)whereimportqualifiedHbro.HbroasHbroimportHbro.TypesimportHbro.UtilimportqualifiedConfig.DyreasDimportConfig.Dyre.CompileimportConfig.Dyre.PathsimportControl.MonadimportGraphics.UI.Gtk.General.Generalhiding(initGUI)importSystem.Console.CmdArgsimportSystem.ExitimportSystem.IOimportSystem.Posix.Signals-- {{{ Commandline optionscliOptions::CliOptionscliOptions=CliOptions{mURI=def&=name"u"&=name"uri"&=typ"URI"&=help"URI to open at start-up"&=explicit,mVanilla=def&=name"1"&=name"vanilla"&=help"Do not read custom configuration file."&=explicit,mRecompile=def&=name"r"&=name"recompile"&=help"Force recompilation and do not launch browser."&=explicit,mDenyReconf=def&=name"deny-reconf"&=help"Deny recompilation even if the configuration file has changed."&=explicit,mForceReconf=def&=name"force-reconf"&=help"Force recompilation even if the configuration file hasn't changed."&=explicit,mDyreDebug=def&=name"dyre-debug"&=help"Force the application to use './cache/' as the cache directory, and ./ as the configuration directory. Useful to debug the program without installation."&=explicit,mMasterBinary=def&=name"dyre-master-binary"&=explicit}getOptions::IOCliOptionsgetOptions=cmdArgs$cliOptions&=verbosityArgs[explicit,name"verbose",name"v"][]&=versionArg[ignore]&=help"A minimal KISS-compliant browser."&=helpArg[explicit,name"help",name"h"]&=program"hbro"-- }}}-- {{{ Dynamic reconfigurationprintDyrePaths::IO()printDyrePaths=getPathsdyreParameters>>=\(a,b,c,d,e)->(putStrLn.unlines)["Current binary: "++a,"Custom binary: "++b,"Config file: "++c,"Cache directory: "++d,"Lib directory: "++e,[]]-- | Launch a recompilation of the configuration filerecompile::IO(MaybeString)recompile=docustomCompiledyreParametersgetErrorStringdyreParametersshowError::(Config',a)->String->(Config',a)showError(_,x)message=(Leftmessage,x)dyreParameters::D.Params(Config',CliOptions)dyreParameters=D.defaultParams{D.projectName="hbro",D.showError=showError,D.realMain=realMain,D.ghcOpts=["-threaded"],D.statusOut=hPutStrLnstderr}-- }}}-- | Browser's main function.-- To be called in main function with a proper configuration.-- See Hbro.Main for an example.hbro::Config->IO()hbroconfig=dooptions<-getOptionswhen(mRecompileoptions)$recompile>>=maybeexitSuccess(\e->putStrLne>>exitFailure)casemVanillaoptionsofTrue->D.wrapMaindyreParameters{D.configCheck=False}(Rightconfig,options)_->D.wrapMaindyreParameters(Rightconfig,options)realMain::(Config',CliOptions)->IO()realMain(Lefte,_)=putStrLnerealMainconfig=dovoid$installHandlersigINT(CatchinterruptHandler)NothingwhenLoudprintDyrePathsHbro.mainconfiginterruptHandler::IO()interruptHandler=logVerbose"Received SIGINT.">>mainQuit