diff options
Diffstat (limited to 'ch23/23_a_1/PodMainCLI.hs')
| -rw-r--r-- | ch23/23_a_1/PodMainCLI.hs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/ch23/23_a_1/PodMainCLI.hs b/ch23/23_a_1/PodMainCLI.hs new file mode 100644 index 0000000..ed26430 --- /dev/null +++ b/ch23/23_a_1/PodMainCLI.hs @@ -0,0 +1,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 --}
|
