1 -- | This module defines the 'Configuration' type, which is just a
2 -- wrapper around all of the configuration options we accept on the
10 import System.Console.CmdArgs.Default ( Default(..) )
11 import System.Log ( Priority( INFO ) )
13 import qualified OptionalConfiguration as OC (OptionalConfiguration(..))
14 import TSN.FeedHosts (FeedHosts(..))
18 feed_hosts :: FeedHosts,
20 log_level :: Priority,
22 output_directory :: FilePath,
27 -- | A Configuration with all of its fields set to their default
29 instance Default Configuration where
30 def = Configuration def "htsn.log" INFO def "." True def
33 -- | Merge a Configuration with an OptionalConfiguration. This is more
34 -- or less the Monoid instance for OptionalConfiguration, but since
35 -- the two types are different, we have to repeat ourselves.
36 merge_optional :: Configuration
37 -> OC.OptionalConfiguration
39 merge_optional cfg opt_cfg =
42 (merge (log_file cfg) (OC.log_file opt_cfg))
43 (merge (log_level cfg) (OC.log_level opt_cfg))
44 (merge (password cfg) (OC.password opt_cfg))
45 (merge (output_directory cfg) (OC.output_directory opt_cfg))
46 (merge (syslog cfg) (OC.syslog opt_cfg))
47 (merge (username cfg) (OC.username opt_cfg))
49 merge :: a -> Maybe a -> a
53 -- If there are any optional usernames, use only those.
54 all_feed_hosts = if (null (get_feed_hosts (OC.feed_hosts opt_cfg)))
56 else (OC.feed_hosts opt_cfg)