diff options
author | Joey Hess <joey@kitenet.net> | 2012-01-06 17:48:02 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-01-06 17:48:02 -0400 |
commit | 3c88d573990d79a5a964567c4a16068ef5ecfa0f (patch) | |
tree | 7fcad82a1c0e55c4d9fe09b819447440d2719e9a | |
parent | 078788a9e755809ac050fd83eb19c4398d7366d7 (diff) |
log --max-count=n
-rw-r--r-- | Command/Log.hs | 20 |
1 files 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 |