X-Git-Url: http://gitweb.michael.orlitzky.com/?p=list-remote-forwards.git;a=blobdiff_plain;f=src%2FMain.hs;h=13371a836d9f7c537583842241db904ec39df1c8;hp=d1d1ea81fa43516bd44b01b294326451b9fbafaf;hb=8e5a377920002012c38066a2d21b6393a78c677a;hpb=d73de26c7c5a72da9d7d64f6c1ed91c3ea2b8dd0 diff --git a/src/Main.hs b/src/Main.hs index d1d1ea8..13371a8 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -12,10 +12,12 @@ import Database.HDBC.Sqlite3 ( connectSqlite3 ) import System.Console.CmdArgs ( def ) import System.Directory ( doesFileExist ) import System.IO ( hPutStrLn, stderr ) + import CommandLine ( get_args ) import Configuration ( Configuration(..), merge_optional ) import qualified OptionalConfiguration as OC ( from_rc ) import Report ( report ) +import String ( trim ) -- | Construct a connection string (postgres-only, for now) from a @@ -23,7 +25,7 @@ import Report ( report ) -- Postgres, and so we want to avoid appending e.g. \"host=\" to the -- connection string if @(host cfg)@ is 'Nothing'. -- --- Examples: +-- ==== __Examples__ -- -- >>> let default_cfg = def :: Configuration -- >>> let cfg = default_cfg { host = Just "localhost" } @@ -37,11 +39,6 @@ connection_string :: Configuration -> String connection_string cfg = trim $ join " " [host_part, port_part, user_part, pw_part, db_part] where - -- | Strip leading/trailing whitespace, and collapse multiple - -- consecutive spaces into one. - trim :: String -> String - trim = unwords . words - host_part = let h = fmap ("host=" ++) (host cfg) in fromMaybe "" h port_part = let p = fmap (("port=" ++) . show) (port cfg) in fromMaybe "" p user_part = let u = fmap ("user=" ++) (username cfg) in fromMaybe "" u @@ -54,7 +51,7 @@ main = do rc_cfg <- OC.from_rc cmd_cfg <- get_args - -- Merge the config file options with the command-line ones, + -- Merge the config file options with the command-line ones, -- prefering the command-line ones. let opt_config = rc_cfg <> cmd_cfg