From 3c88d573990d79a5a964567c4a16068ef5ecfa0f Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 6 Jan 2012 17:48:02 -0400 Subject: log --max-count=n --- Command/Log.hs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/Command/Log.hs b/Command/Log.hs index 2651b14be..ff217e573 100644 --- a/Command/Log.hs +++ b/Command/Log.hs @@ -26,23 +26,29 @@ import qualified Remote import qualified Option def :: [Command] -def = [withOptions [afterOption] $ +def = [withOptions [afterOption, maxcountOption] $ command "log" paramPaths seek "shows location log"] afterOption :: Option afterOption = Option.field [] "after" paramDate "show log after date" +maxcountOption :: Option +maxcountOption = Option.field ['n'] "max-count" paramNumber "limit number of logs displayed" + seek :: [CommandSeek] seek = [withField afterOption return $ \afteropt -> - withFilesInGit $ whenAnnexed $ start afteropt] + withField maxcountOption return $ \maxcount -> + withFilesInGit $ whenAnnexed $ start afteropt maxcount] -start :: Maybe String -> FilePath -> (Key, Backend) -> CommandStart -start afteropt file (key, _) = do - let ps = case afteropt of - Nothing -> [] - Just date -> [Param "--after", Param date] +start :: Maybe String -> Maybe String -> FilePath -> (Key, Backend) -> CommandStart +start afteropt maxcount file (key, _) = do showLog file =<< (readLog <$> getLog key ps) stop + where + ps = concatMap (\(o, p) -> maybe [] p o) + [ (afteropt, \d -> [Param "--after", Param d]) + , (maxcount, \c -> [Param "--max-count", Param c]) + ] showLog :: FilePath -> [(POSIXTime, (Git.Ref, Git.Ref))] -> Annex () showLog file ps = do -- cgit v1.2.3