summaryrefslogtreecommitdiff
path: root/src/Propellor/CmdLine.hs
diff options
context:
space:
mode:
authorJoey Hess2014-11-22 15:54:31 -0400
committerJoey Hess2014-11-22 15:54:31 -0400
commit40339a7fd830503a09b54138372a159c8bc342d7 (patch)
tree9ba9a28c8bc59d9aeade5c6e7861b2cf33a2dce7 /src/Propellor/CmdLine.hs
parent97931fe6700be054e6e5e26da9a9f47e88ba6a2a (diff)
propellor spin
Diffstat (limited to 'src/Propellor/CmdLine.hs')
-rw-r--r--src/Propellor/CmdLine.hs16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/Propellor/CmdLine.hs b/src/Propellor/CmdLine.hs
index 2bd07614..ea6cabff 100644
--- a/src/Propellor/CmdLine.hs
+++ b/src/Propellor/CmdLine.hs
@@ -53,9 +53,8 @@ processCmdLine = go =<< getArgs
exitFailure
go ("--update":_:[]) = return $ Update Nothing
go ("--boot":_:[]) = return $ Update Nothing -- for back-compat
- go ("--continue":s:[]) = case readish s of
- Just cmdline -> return $ Continue cmdline
- Nothing -> errorMessage $ "--continue serialization failure (" ++ s ++ ")"
+ go ("--serialized":s:[]) = serialized Serialized s
+ go ("--continue":s:[]) = serialized Continue s
go ("--gitpush":fin:fout:_) = return $ GitPush (Prelude.read fin) (Prelude.read fout)
go (h:[])
| "--" `isPrefixOf` h = usageError [h]
@@ -71,6 +70,10 @@ processCmdLine = go =<< getArgs
Just pf -> return $ f pf (Context c)
Nothing -> errorMessage $ "Unknown privdata field " ++ s
+ serialized mk s = case readish s of
+ Just cmdline -> return $ mk cmdline
+ Nothing -> errorMessage $ "serialization failure (" ++ s ++ ")"
+
-- | Runs propellor on hosts, as controlled by command-line options.
defaultMain :: [Host] -> IO ()
defaultMain hostlist = do
@@ -80,6 +83,7 @@ defaultMain hostlist = do
debug ["command line: ", show cmdline]
go True cmdline
where
+ go _ (Serialized cmdline) = go True cmdline
go _ (Continue cmdline) = go False cmdline
go _ (Set field context) = setPrivData field context
go _ (Dump field context) = dumpPrivData field context
@@ -196,10 +200,10 @@ spin target relay hst = do
, "fi"
]
- runcmd = mkcmd [ "cd " ++ localdir ++ " && ./propellor --continue " ++ shellEscape (show cmd) ]
+ runcmd = mkcmd [ "cd " ++ localdir ++ " && ./propellor " ++ cmd ]
cmd = if isNothing relay
- then SimpleRun target
- else Spin target (Just target)
+ then "--continue " ++ shellEscape (show (SimpleRun target))
+ else "--serialized " ++ shellEscape (show (Spin target (Just target)))
runparams = catMaybes
[ if isJust relay then Just "-A" else Nothing
, Just "-t"