aboutsummaryrefslogtreecommitdiff
path: root/Command/Log.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-03-29 14:39:16 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-03-29 14:39:16 -0400
commit3d7b8ab9a31b0fe50b602efade89b390f471d562 (patch)
tree3bb4668eba093a527750e152920f8a50f1e4ba5c /Command/Log.hs
parent278f84fe6458a2ac8e12ecab8f2b4f4bb7d0122c (diff)
log --raw-date: Use to display seconds from unix epoch.
Diffstat (limited to 'Command/Log.hs')
-rw-r--r--Command/Log.hs16
1 files changed, 11 insertions, 5 deletions
diff --git a/Command/Log.hs b/Command/Log.hs
index 4a680111e..808b86b70 100644
--- a/Command/Log.hs
+++ b/Command/Log.hs
@@ -44,6 +44,7 @@ cmd = withGlobalOptions annexedMatchingOptions $
data LogOptions = LogOptions
{ logFiles :: CmdParams
+ , rawDateOption :: Bool
, gourceOption :: Bool
, passthruOptions :: [CommandParam]
}
@@ -52,6 +53,10 @@ optParser :: CmdParamsDesc -> Parser LogOptions
optParser desc = LogOptions
<$> cmdParams desc
<*> switch
+ ( long "raw-date"
+ <> help "display seconds from unix epoch"
+ )
+ <*> switch
( long "gource"
<> help "format output for gource"
)
@@ -92,8 +97,9 @@ start m zone o file key = do
stop
where
output
- | (gourceOption o) = gourceOutput lookupdescription file
- | otherwise = normalOutput lookupdescription file zone
+ | rawDateOption o = normalOutput lookupdescription file show
+ | gourceOption o = gourceOutput lookupdescription file
+ | otherwise = normalOutput lookupdescription file (showTimeStamp zone)
lookupdescription u = fromMaybe (fromUUID u) $ M.lookup u m
showLog :: Outputter -> [RefChange] -> Annex ()
@@ -109,11 +115,11 @@ showLog outputter ps = do
get ref = map toUUID . Logs.Presence.getLog . L.unpack <$>
catObject ref
-normalOutput :: (UUID -> String) -> FilePath -> TimeZone -> Outputter
-normalOutput lookupdescription file zone present ts us =
+normalOutput :: (UUID -> String) -> FilePath -> (POSIXTime -> String) -> Outputter
+normalOutput lookupdescription file formattime present ts us =
liftIO $ mapM_ (putStrLn . format) us
where
- time = showTimeStamp zone ts
+ time = formattime ts
addel = if present then "+" else "-"
format u = unwords [ addel, time, file, "|",
fromUUID u ++ " -- " ++ lookupdescription u ]