Skip to content
This repository has been archived by the owner on Jul 10, 2020. It is now read-only.

Commit

Permalink
Implement formatted output of podcasts
Browse files Browse the repository at this point in the history
  • Loading branch information
mkpankov committed Apr 11, 2014
1 parent 175e889 commit db2464d
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions Main.hs
Expand Up @@ -3,6 +3,7 @@
module Main where

import Control.Monad
import Data.List (intersperse)
import Data.Time
import Data.DateTime
import Database.HDBC
Expand Down Expand Up @@ -34,7 +35,7 @@ instance Attributes Commands where
guests %> Help "Guests of the episode",
topics %> Help "Topics of the episode",
start %> [ Help "Start date and time"
, Default "01/01/14 00:00" ]
, Default "2014-01-01 00:00:00.0" ]
],
group "Showing the podcasts" [
numberToShow %> Help "How much podcasts to display"
Expand Down Expand Up @@ -93,6 +94,17 @@ showPodcasts _ = do
conn <- connectSqlite3 databaseFilePath
rows <- quickQuery conn ("SELECT number, topics, guests, start_ " ++
" FROM podcasts") []
print rows
mapM_ showPodcast rows
disconnect conn
return ()

showPodcast :: [SqlValue] -> IO ()
showPodcast values = do
let number : topics : guests : start_ : [] = values
putStrLn $ "Episode " ++ show (fromSql number :: Int)
putStrLn $ "Topics:\n " ++ (
concat $ intersperse "\n " (csv $ (fromSql topics :: String)))
putStrLn $ "Guests:\n " ++ (
concat $ intersperse ", " (csv $ (fromSql guests :: String)))
putStrLn $ "Start: " ++ show (fromSql start_ :: UTCTime)
putStrLn ""

0 comments on commit db2464d

Please sign in to comment.