feed-cli 2008.5.3 → 2009.7.5
raw patch · 3 files changed
+18/−9 lines, 3 filesdep ~base
Dependency ranges changed: base
Files
- FeedCLI.hs +8/−5
- Options.hs +6/−0
- feed-cli.cabal +4/−4
FeedCLI.hs view
@@ -67,17 +67,18 @@ writeRSS :: Maybe FilePath -- If they haven't provided an argument, stdout. -> RSS -> Bool -- ^create a temporary file?+ -> FilePath -- ^directory for temporary files -> IO ()-writeRSS (Just outFile) rss createTemp = do+writeRSS (Just outFile) rss createTemp tmpDir = do (fileToWrite, h) <- if createTemp- then openTempFile "/tmp" ("rssGenTemp.xml") -- fix: portable?+ then openTempFile tmpDir ("rssGenTemp.xml") -- fix: portable? else do h' <- openFile outFile WriteMode return (outFile, h') hPutStr h (showTopElement $ xmlRSS rss) hClose h when createTemp (renameFile fileToWrite outFile) -writeRSS Nothing rss _ = putStrLn $ showTopElement $ xmlRSS rss+writeRSS Nothing rss _ _ = putStrLn $ showTopElement $ xmlRSS rss -- Throw some sane exceptions open file fail, etc. Creates basic empty feed if it doesn't exist readRSS :: FilePath -> IO RSS@@ -127,6 +128,7 @@ let inFile = fromMaybe (error "infile required") (optInput opts) let createTemp = Just inFile == mOutFile let mLimit = optLimit opts+ let tmpDir = optTmpDir opts feedDescription <- getDescription (optDescription opts) (optPreDesc opts) @@ -144,7 +146,7 @@ KeepLimit -> limitItems feedWithItem (fromIntegral $ length $ rssItems $ rssChannel readFeed) NumLimit lim -> limitItems feedWithItem lim- writeRSS mOutFile newFeed createTemp+ writeRSS mOutFile newFeed createTemp tmpDir getDescription :: DescType@@ -166,11 +168,12 @@ desc <- getDescription (optDescription opts) (optPreDesc opts) let mLink = optLink opts let link = fromMaybe (error "--link required") mLink+ let tmpDir = optTmpDir opts let newRSS = nullRSS title link let newChannel = (rssChannel newRSS){rssDescription = desc} - writeRSS mOutFile newRSS{rssChannel=newChannel} False+ writeRSS mOutFile newRSS{rssChannel=newChannel} False tmpDir ------------------------------------------------------------
Options.hs view
@@ -19,6 +19,7 @@ , optPreDesc :: Bool , optOutput :: Maybe FilePath , optInput :: Maybe FilePath+ , optTmpDir :: FilePath , optDescription :: DescType , optLimit :: LimitType , optTitle :: String@@ -31,6 +32,7 @@ , optShowVersion = False , optPreDesc = False , optOutput = Nothing+ , optTmpDir = "/tmp" , optInput = Nothing , optLimit = NoLimit , optTitle = ""@@ -66,6 +68,10 @@ , Option ['o'] ["output"] (ReqArg ((\ f opts -> opts { optOutput = Just f })) "FILE") "output to this file, or -u"++ , Option [] ["tmp"]+ (ReqArg ((\ f opts -> opts { optTmpDir = f })) "FILE")+ "directory for temporary files; defaults to /tmp" , Option ['u'] ["update-file"] (ReqArg ((\ f opts -> opts { optInput = Just f
feed-cli.cabal view
@@ -1,13 +1,13 @@ Name: feed-cli-Version: 2008.5.3+Version: 2009.7.5 Author: Isaac Potoczny-Jones <ijones@syntaxpolice.org> Maintainer: Isaac Potoczny-Jones <ijones@syntaxpolice.org>-Copyright: (c) Isaac Potoczny-Jones, 2008+Copyright: (c) Isaac Potoczny-Jones, 2008-2009 Category: Web, Text HomePage: http://www.syntaxpolice.org/darcs_repos/feed-cli License: BSD3 License-File: LICENSE-build-depends: feed, xml, base, time, old-locale, old-time, directory+build-depends: feed, xml, base < 4, time, old-locale, old-time, directory data-files: README, examples/getURL.sh, examples/piper2.sh, examples/piper.sh build-type: Simple Synopsis: A simple command line interface for creating and updating feeds like RSS@@ -17,7 +17,7 @@ feeds from shell scripts, build scripts, cron jobs, CGIs, or other programs instead of using an RSS or Atom library. .- eg: feed-cli new-item -t"entry of the day" -d"This is a description..." -u/tmp/feed.xml -lhttp://www.syntaxpolice.org+ eg: ./feed-cli new-item -t"entry of the day" -d"This is a description..." -u/tmp/feed.xml -lhttp://www.syntaxpolice.org Executable: feed-cli main-is: FeedCLI.hs