summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CmdLine/GitAnnex.hs4
-rw-r--r--Command/Log.hs65
2 files changed, 39 insertions, 30 deletions
diff --git a/CmdLine/GitAnnex.hs b/CmdLine/GitAnnex.hs
index 37f5ce8ba..bbd66eca8 100644
--- a/CmdLine/GitAnnex.hs
+++ b/CmdLine/GitAnnex.hs
@@ -60,7 +60,7 @@ import qualified Command.Find
import qualified Command.FindRef
import qualified Command.Whereis
import qualified Command.List
---import qualified Command.Log
+import qualified Command.Log
import qualified Command.Merge
import qualified Command.ResolveMerge
import qualified Command.Info
@@ -187,7 +187,7 @@ cmds =
, Command.FindRef.cmd
, Command.Whereis.cmd
, Command.List.cmd
--- , Command.Log.cmd
+ , Command.Log.cmd
, Command.Merge.cmd
, Command.ResolveMerge.cmd
, Command.Info.cmd
diff --git a/Command/Log.hs b/Command/Log.hs
index eb740b249..86b32b937 100644
--- a/Command/Log.hs
+++ b/Command/Log.hs
@@ -39,52 +39,61 @@ data RefChange = RefChange
type Outputter = Bool -> POSIXTime -> [UUID] -> Annex ()
cmd :: Command
-cmd = withGlobalOptions options $
+cmd = withGlobalOptions annexedMatchingOptions $
command "log" SectionQuery "shows location log"
- paramPaths (withParams seek)
+ paramPaths (seek <$$> optParser)
-options :: [GlobalOption]
-options = passthruOptions ++ [gourceOption] ++ annexedMatchingOptions
+data LogOptions = LogOptions
+ { logFiles :: CmdParams
+ , gourceOption :: Bool
+ , passthruOptions :: [CommandParam]
+ }
-passthruOptions :: [Option]
-passthruOptions = map odate ["since", "after", "until", "before"] ++
- [ fieldOption ['n'] "max-count" paramNumber
- "limit number of logs displayed"
- ]
+optParser :: CmdParamsDesc -> Parser LogOptions
+optParser desc = LogOptions
+ <$> cmdParams desc
+ <*> switch
+ ( long "gource"
+ <> help "format output for gource"
+ )
+ <*> (concat <$> many passthru)
where
- odate n = fieldOption [] n paramDate $ "show log " ++ n ++ " date"
-
-gourceOption :: Option
-gourceOption = flagOption [] "gource" "format output for gource"
-
-seek :: CmdParams -> CommandSeek
-seek ps = do
+ passthru :: Parser [CommandParam]
+ passthru = datepassthru "since"
+ <|> datepassthru "after"
+ <|> datepassthru "until"
+ <|> datepassthru "before"
+ <|> (mkpassthru "max-count" <$> strOption
+ ( long "max-count" <> metavar paramNumber
+ <> help "limit number of logs displayed"
+ ))
+ datepassthru n = mkpassthru n <$> strOption
+ ( long n <> metavar paramDate
+ <> help ("show log " ++ n ++ " date")
+ )
+ mkpassthru n v = [Param ("--" ++ n), Param v]
+
+seek :: LogOptions -> CommandSeek
+seek o = do
m <- Remote.uuidDescriptions
zone <- liftIO getCurrentTimeZone
- os <- concat <$> mapM getoption passthruOptions
- gource <- getOptionFlag gourceOption
- withFilesInGit (whenAnnexed $ start m zone os gource) ps
- where
- getoption o = maybe [] (use o) <$>
- Annex.getField (optionName o)
- use o v = [Param ("--" ++ optionName o), Param v]
+ withFilesInGit (whenAnnexed $ start m zone o) (logFiles o)
start
:: M.Map UUID String
-> TimeZone
- -> [CommandParam]
- -> Bool
+ -> LogOptions
-> FilePath
-> Key
-> CommandStart
-start m zone os gource file key = do
- showLog output =<< readLog <$> getLog key os
+start m zone o file key = do
+ showLog output =<< readLog <$> getLog key (passthruOptions o)
-- getLog produces a zombie; reap it
liftIO reapZombies
stop
where
output
- | gource = gourceOutput lookupdescription file
+ | (gourceOption o) = gourceOutput lookupdescription file
| otherwise = normalOutput lookupdescription file zone
lookupdescription u = fromMaybe (fromUUID u) $ M.lookup u m