blob: ed26430f66909ef84aeab4be39b848876ec4b151 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
{-- From examples/examples/ch22/PodMain.hs and modified --}
module Main where
import PodMain
import PodDownload
import PodDB
import PodTypes
import System.Environment
import Database.HDBC
import Network.Socket(withSocketsDo)
main = withSocketsDo $ handleSqlError $
do args <- getArgs
dbh <- connect "pod.db"
case args of
["add", url] -> addUrl dbh url
["update"] -> update dbh putStrLn
["download"] -> download dbh putStrLn
["fetch"] -> do update dbh putStrLn
download dbh putStrLn
_ -> syntaxError
disconnect dbh
syntaxError = putStrLn
"Usage: pod command [args]\n\
\\n\
\pod add url Adds a new podcast with the given URL\n\
\pod download Downloads all pending episodes\n\
\pod fetch Updates, then downloads\n\
\pod update Downloads podcast feeds, looks for new episodes\n"
{-- End of code from examples --}
|