{-|
Module      : Main
Description : Main module for 'breadu-exe' program
Stability   : experimental
Portability : POSIX

Main module for 'breadu-exe' program. This program is very simple,
it just uses 'breadu' library to run a server.
-}

module Main where

-- This space after 'import' keyword is for 'qualified' word.
-- So if some module(s) is qualified-imported, modules keep vertical aligned by names.
-- Good practice: specify imported types/functions explicitly, it'll help to project's maintainers.
import           CLI                            ( optionsParser, makeSureOptionsAreValid )
import           BreadU                         ( startBreadU )

-- Special autogenerated module with metadata obtained from .cabal-file.
import           Paths_breadu                   ( version )

import           Data.Version                   ( showVersion )
import           Options.Applicative.Simple     ( simpleOptions, empty )

-- | Main function, app's entry point.
main :: IO ()
main =
    simpleOptions (showVersion version)
                  "Bread Unit calculator for diabetics"
                  "Runs server, listen defined port at localhost"
                  optionsParser
                  empty
    >>= makeSureOptionsAreValid
    >>= startBreadU
