converted Log
This commit is contained in:
parent
3d8a8e9792
commit
3639b4f8ea
2 changed files with 38 additions and 29 deletions
|
@ -60,7 +60,7 @@ import qualified Command.Find
|
||||||
import qualified Command.FindRef
|
import qualified Command.FindRef
|
||||||
import qualified Command.Whereis
|
import qualified Command.Whereis
|
||||||
import qualified Command.List
|
import qualified Command.List
|
||||||
--import qualified Command.Log
|
import qualified Command.Log
|
||||||
import qualified Command.Merge
|
import qualified Command.Merge
|
||||||
import qualified Command.ResolveMerge
|
import qualified Command.ResolveMerge
|
||||||
import qualified Command.Info
|
import qualified Command.Info
|
||||||
|
@ -187,7 +187,7 @@ cmds =
|
||||||
, Command.FindRef.cmd
|
, Command.FindRef.cmd
|
||||||
, Command.Whereis.cmd
|
, Command.Whereis.cmd
|
||||||
, Command.List.cmd
|
, Command.List.cmd
|
||||||
-- , Command.Log.cmd
|
, Command.Log.cmd
|
||||||
, Command.Merge.cmd
|
, Command.Merge.cmd
|
||||||
, Command.ResolveMerge.cmd
|
, Command.ResolveMerge.cmd
|
||||||
, Command.Info.cmd
|
, Command.Info.cmd
|
||||||
|
|
|
@ -39,52 +39,61 @@ data RefChange = RefChange
|
||||||
type Outputter = Bool -> POSIXTime -> [UUID] -> Annex ()
|
type Outputter = Bool -> POSIXTime -> [UUID] -> Annex ()
|
||||||
|
|
||||||
cmd :: Command
|
cmd :: Command
|
||||||
cmd = withGlobalOptions options $
|
cmd = withGlobalOptions annexedMatchingOptions $
|
||||||
command "log" SectionQuery "shows location log"
|
command "log" SectionQuery "shows location log"
|
||||||
paramPaths (withParams seek)
|
paramPaths (seek <$$> optParser)
|
||||||
|
|
||||||
options :: [GlobalOption]
|
data LogOptions = LogOptions
|
||||||
options = passthruOptions ++ [gourceOption] ++ annexedMatchingOptions
|
{ logFiles :: CmdParams
|
||||||
|
, gourceOption :: Bool
|
||||||
|
, passthruOptions :: [CommandParam]
|
||||||
|
}
|
||||||
|
|
||||||
passthruOptions :: [Option]
|
optParser :: CmdParamsDesc -> Parser LogOptions
|
||||||
passthruOptions = map odate ["since", "after", "until", "before"] ++
|
optParser desc = LogOptions
|
||||||
[ fieldOption ['n'] "max-count" paramNumber
|
<$> cmdParams desc
|
||||||
"limit number of logs displayed"
|
<*> switch
|
||||||
]
|
( long "gource"
|
||||||
|
<> help "format output for gource"
|
||||||
|
)
|
||||||
|
<*> (concat <$> many passthru)
|
||||||
where
|
where
|
||||||
odate n = fieldOption [] n paramDate $ "show log " ++ n ++ " date"
|
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]
|
||||||
|
|
||||||
gourceOption :: Option
|
seek :: LogOptions -> CommandSeek
|
||||||
gourceOption = flagOption [] "gource" "format output for gource"
|
seek o = do
|
||||||
|
|
||||||
seek :: CmdParams -> CommandSeek
|
|
||||||
seek ps = do
|
|
||||||
m <- Remote.uuidDescriptions
|
m <- Remote.uuidDescriptions
|
||||||
zone <- liftIO getCurrentTimeZone
|
zone <- liftIO getCurrentTimeZone
|
||||||
os <- concat <$> mapM getoption passthruOptions
|
withFilesInGit (whenAnnexed $ start m zone o) (logFiles o)
|
||||||
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]
|
|
||||||
|
|
||||||
start
|
start
|
||||||
:: M.Map UUID String
|
:: M.Map UUID String
|
||||||
-> TimeZone
|
-> TimeZone
|
||||||
-> [CommandParam]
|
-> LogOptions
|
||||||
-> Bool
|
|
||||||
-> FilePath
|
-> FilePath
|
||||||
-> Key
|
-> Key
|
||||||
-> CommandStart
|
-> CommandStart
|
||||||
start m zone os gource file key = do
|
start m zone o file key = do
|
||||||
showLog output =<< readLog <$> getLog key os
|
showLog output =<< readLog <$> getLog key (passthruOptions o)
|
||||||
-- getLog produces a zombie; reap it
|
-- getLog produces a zombie; reap it
|
||||||
liftIO reapZombies
|
liftIO reapZombies
|
||||||
stop
|
stop
|
||||||
where
|
where
|
||||||
output
|
output
|
||||||
| gource = gourceOutput lookupdescription file
|
| (gourceOption o) = gourceOutput lookupdescription file
|
||||||
| otherwise = normalOutput lookupdescription file zone
|
| otherwise = normalOutput lookupdescription file zone
|
||||||
lookupdescription u = fromMaybe (fromUUID u) $ M.lookup u m
|
lookupdescription u = fromMaybe (fromUUID u) $ M.lookup u m
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue