]> gitweb.michael.orlitzky.com - list-remote-forwards.git/blobdiff - src/Main.hs
Add a doctest test suite.
[list-remote-forwards.git] / src / Main.hs
index d1d1ea81fa43516bd44b01b294326451b9fbafaf..13371a836d9f7c537583842241db904ec39df1c8 100644 (file)
@@ -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