X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2FConfiguration.hs;h=4d9a1c659c3420c33d1a55448c576280a8460270;hb=HEAD;hp=168136a58ad6adb25bc72df12404d98e52acc7fc;hpb=cdd0f36ab4aa8aadc416f6b9cbe6117c26d2ddf2;p=dead%2Fhtsn-import.git diff --git a/src/Configuration.hs b/src/Configuration.hs index 168136a..4d9a1c6 100644 --- a/src/Configuration.hs +++ b/src/Configuration.hs @@ -7,23 +7,28 @@ module Configuration ( merge_optional ) where +-- System imports. import System.Console.CmdArgs.Default ( Default(..) ) import System.Log ( Priority( INFO ) ) +-- Local imports. import Backend ( Backend(..) ) import ConnectionString ( ConnectionString ) import qualified OptionalConfiguration as OC ( OptionalConfiguration(..), merge_maybes ) --- | The main configuration data type. This will be passed to most of --- the important functions once it has been created. + +-- | The main configuration data type. It contains all options that +-- can be set in a config file or on the command line. +-- data Configuration = Configuration { backend :: Backend, connection_string :: ConnectionString, log_file :: Maybe FilePath, log_level :: Priority, + remove :: Bool, syslog :: Bool } deriving (Show) @@ -35,12 +40,14 @@ instance Default Configuration where connection_string = def, log_file = def, log_level = INFO, + remove = def, syslog = def } -- | Merge a Configuration with an OptionalConfiguration. This is more --- or less the Monoid instance for OptionalConfiguration, but since +-- or less the Monoid instance for 'OptionalConfiguration', but since -- the two types are different, we have to repeat ourselves. +-- merge_optional :: Configuration -> OC.OptionalConfiguration -> Configuration @@ -50,6 +57,7 @@ merge_optional cfg opt_cfg = (merge (connection_string cfg) (OC.connection_string opt_cfg)) (OC.merge_maybes (log_file cfg) (OC.log_file opt_cfg)) (merge (log_level cfg) (OC.log_level opt_cfg)) + (merge (remove cfg) (OC.remove opt_cfg)) (merge (syslog cfg) (OC.syslog opt_cfg)) where -- | If the thing on the right is Just something, return that