sim visit as first-class command

Allows using it in a sim file.
This commit is contained in:
Joey Hess 2024-09-23 13:09:35 -04:00
parent 6cf9a101b8
commit 7bc8c2bfeb
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
4 changed files with 48 additions and 34 deletions

View file

@ -80,6 +80,8 @@ generateSimFile = unlines . map unwords . go
["maxsize", repo, showsize (fromMaxSize maxsize)] : go rest
go (CommandRebalance b : rest) =
["rebalance", if b then "on" else "off"] : go rest
go (CommandVisit (RepoName repo) cmdparams : rest) =
(["visit", repo] ++ cmdparams) : go rest
go (CommandComment s : rest) =
[s] : go rest
go (CommandBlank : rest) =
@ -184,6 +186,8 @@ parseSimCommand ("maxsize":repo:size:[]) =
parseSimCommand ("rebalance":onoff:[]) = case isTrueFalse onoff of
Just b -> Right $ CommandRebalance b
Nothing -> Left $ "Unable to parse rebalance value \"" ++ onoff ++ "\""
parseSimCommand ("visit":repo:cmdparams) =
Right $ CommandVisit (RepoName repo) cmdparams
parseSimCommand ws = parseError ws
parseSimAction :: [String] -> Either String SimAction