This commit is contained in:
Joey Hess 2024-09-17 11:19:59 -04:00
parent 2a16796a1c
commit 4c7db31c20
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
4 changed files with 43 additions and 3 deletions

View file

@ -49,6 +49,8 @@ generateSimFile = unlines . map unwords . go
["addtree", name, expr] : go rest
go (CommandAdd f sz repos : rest) =
(["add", fromRawFilePath f, showsize sz] ++ map fromRepoName repos) : go rest
go (CommandAddMulti n suffix minsz maxsz repos : rest) =
(["addmulti", show n, suffix, showsize minsz, showsize maxsz] ++ map fromRepoName repos) : go rest
go (CommandStep n : rest) =
["step", show n] : go rest
go (CommandAction act : rest) = formatAction act : go rest
@ -127,6 +129,16 @@ parseSimCommand ("add":filename:size:repos) =
sz
(map RepoName repos)
Nothing -> Left $ "Unable to parse file size \"" ++ size ++ "\""
parseSimCommand ("addmulti":num:suffix:minsize:maxsize:repos) =
case readSize dataUnits minsize of
Just minsz -> case readSize dataUnits maxsize of
Just maxsz -> case readMaybe num of
Just n -> Right $ CommandAddMulti
n suffix minsz maxsz
(map RepoName repos)
Nothing -> Left $ "Unable to parse number \"" ++ num ++ "\""
Nothing -> Left $ "Unable to parse file size \"" ++ maxsize ++ "\""
Nothing -> Left $ "Unable to parse file size \"" ++ minsize ++ "\""
parseSimCommand ("step":n:[]) =
case readMaybe n of
Just n' -> Right $ CommandStep n'