summaryrefslogtreecommitdiff
path: root/Propellor/CmdLine.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Propellor/CmdLine.hs')
-rw-r--r--Propellor/CmdLine.hs14
1 files changed, 7 insertions, 7 deletions
diff --git a/Propellor/CmdLine.hs b/Propellor/CmdLine.hs
index 3939309d..c36c1377 100644
--- a/Propellor/CmdLine.hs
+++ b/Propellor/CmdLine.hs
@@ -52,11 +52,12 @@ usage = do
defaultMain :: (HostName -> Maybe [Property]) -> IO ()
defaultMain getprops = go =<< processCmdLine
where
- go (Run host) = maybe (unknownhost host) ensureProperties (getprops host)
- go (Spin host) = spin host
- go (Boot host) = maybe (unknownhost host) boot (getprops host)
+ go (Run host) = withprops host ensureProperties
+ go (Spin host) = withprops host (const $ spin host)
+ go (Boot host) = withprops host boot
go (Set host field) = setPrivData host field
go (AddKey keyid) = addKey keyid
+ withprops host a = maybe (unknownhost host) a (getprops host)
unknownhost :: HostName -> IO a
unknownhost h = error $ unwords
@@ -74,11 +75,10 @@ spin host = do
status <- getstatus fromh `catchIO` error "protocol error"
case status of
NeedKeyRing -> do
- s <- w82s . BL.unpack . B64.encode
- <$> BL.readFile keyring
- putStr $ "Sending " ++ keyring ++ " (" ++ show (BL.length s) ++ " bytes) to " ++ host ++ "..."
+ d <- BL.readFile keyring
+ putStr $ "Sending " ++ keyring ++ " (" ++ show (BL.length d) ++ " bytes) to " ++ host ++ "..."
hFlush stdout
- hPutStrLn toh $ toMarked keyringMarker s
+ hPutStrLn toh $ toMarked keyringMarker $ w82s $ BL.unpack $ B64.encode d
hFlush toh
putStrLn "done"
HaveKeyRing -> noop