1 -- | This module defines the 'Configuration' type, which is just a
2 -- wrapper around all of the configuration options we accept on the
3 -- command line. We thread this throughout the rest of the program.
10 import System.Console.CmdArgs.Default (Default(..))
12 import qualified OptionalConfiguration as OC (OptionalConfiguration(..))
13 import TSN.FeedHosts (FeedHosts(..))
17 feed_hosts :: FeedHosts,
19 output_directory :: FilePath,
23 -- | A Configuration with all of its fields set to their default
25 instance Default Configuration where
26 def = Configuration def def "." def
28 merge_optional :: Configuration
29 -> OC.OptionalConfiguration
31 merge_optional cfg opt_cfg =
34 (merge (password cfg) (OC.password opt_cfg))
35 (merge (output_directory cfg) (OC.output_directory opt_cfg))
36 (merge (username cfg) (OC.username opt_cfg))
38 merge :: a -> Maybe a -> a
42 -- If there are any optional usernames, use only those.
43 all_feed_hosts = if (null (get_feed_hosts (OC.feed_hosts opt_cfg)))
45 else (OC.feed_hosts opt_cfg)