2024-09-04 19:10:39 +00:00
|
|
|
{- git-annex command
|
|
|
|
-
|
|
|
|
- Copyright 2024 Joey Hess <id@joeyh.name>
|
|
|
|
-
|
|
|
|
- Licensed under the GNU AGPL version 3 or higher.
|
|
|
|
-}
|
|
|
|
|
2024-09-11 14:32:04 +00:00
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
|
|
|
|
2024-09-04 19:10:39 +00:00
|
|
|
module Command.Sim where
|
|
|
|
|
|
|
|
import Command
|
|
|
|
import Annex.Sim
|
2024-09-11 15:53:25 +00:00
|
|
|
import Annex.Sim.File
|
2024-09-09 14:59:01 +00:00
|
|
|
import Utility.Tmp.Dir
|
|
|
|
|
|
|
|
import System.Random
|
2024-09-04 19:10:39 +00:00
|
|
|
|
|
|
|
cmd :: Command
|
|
|
|
cmd = command "sim" SectionTesting
|
|
|
|
"simulate a network of repositories"
|
|
|
|
paramCommand (withParams seek)
|
|
|
|
|
|
|
|
seek :: CmdParams -> CommandSeek
|
2024-09-09 14:59:01 +00:00
|
|
|
seek _ = do
|
|
|
|
rng <- initStdGen
|
|
|
|
repobyname <- mkGetExistingRepoByName
|
|
|
|
withTmpDir "sim" $ \tmpdir -> do
|
2024-09-11 14:32:04 +00:00
|
|
|
let getpath = GetSimRepoPath $ \u -> tmpdir </> fromUUID u
|
|
|
|
let st = emptySimState rng repobyname getpath
|
2024-09-09 14:59:01 +00:00
|
|
|
st' <- runSimCommand (CommandInit (RepoName "foo")) st
|
|
|
|
>>= runSimCommand (CommandUse (RepoName "bar") "here")
|
2024-09-11 15:53:25 +00:00
|
|
|
>>= runSimCommand (CommandAdd "bigfile" 1000000 [RepoName "foo"])
|
2024-09-11 14:32:04 +00:00
|
|
|
>>= runSimCommand (CommandAction (RepoName "bar") (ActionGitPull (RemoteName "foo")))
|
|
|
|
>>= runSimCommand (CommandAction (RepoName "bar") (ActionGetWanted (RemoteName "foo")))
|
|
|
|
st'' <- liftIO $ updateSimRepos st'
|
2024-09-09 14:59:01 +00:00
|
|
|
liftIO $ print tmpdir
|
|
|
|
_ <- liftIO $ getLine
|
|
|
|
return ()
|
|
|
|
|