sim file parser and generator

The generator doesn't emit the best possible connect commands,
but it does output something valid. Eg, an input like:

connect A <-> B <-> C <-> D

becomes:

connect A <-> B <-> C
connect C <-> D

Also:

connect A -> B <- C

becomes:

connect A -> B
connect C -> B

Which could be improved.

Also disconnect commands are not prettified at all, but probably there's
no reason to.
This commit is contained in:
Joey Hess 2024-09-11 15:59:13 -04:00
parent 84bbbeae9d
commit f381b457f2
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
4 changed files with 172 additions and 54 deletions

View file

@ -29,7 +29,6 @@ seek _ = do
let getpath = GetSimRepoPath $ \u -> tmpdir </> fromUUID u
let st = emptySimState rng repobyname getpath
st' <- runSimCommand (CommandInit (RepoName "foo")) st
>>= runSimCommand (CommandTrustLevel (RepoName "foo") "trusted")
>>= runSimCommand (CommandUse (RepoName "bar") "here")
>>= runSimCommand (CommandConnect (RepoName "foo") (RemoteName "bar"))
>>= runSimCommand (CommandConnect (RepoName "bar") (RemoteName "foo"))