summaryrefslogtreecommitdiff
path: root/src/Propellor/CmdLine.hs
diff options
context:
space:
mode:
authorJoey Hess2014-11-18 20:29:31 -0400
committerJoey Hess2014-11-18 20:29:31 -0400
commitcdad4fbe15dbc42524d591463731898fa3d73e43 (patch)
tree432feaf1201110366cc04c7b41a1bfd1a3404212 /src/Propellor/CmdLine.hs
parent2ad3334b26648157f7c7e2c584b3eaf99b9bce89 (diff)
propellor spin
Diffstat (limited to 'src/Propellor/CmdLine.hs')
-rw-r--r--src/Propellor/CmdLine.hs12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/Propellor/CmdLine.hs b/src/Propellor/CmdLine.hs
index ab6d8619..2f56c184 100644
--- a/src/Propellor/CmdLine.hs
+++ b/src/Propellor/CmdLine.hs
@@ -21,9 +21,9 @@ import qualified Propellor.Property.Docker.Shim as DockerShim
import Utility.FileMode
import Utility.SafeCommand
-usage :: IO a
-usage = do
- putStrLn $ unlines
+usage :: Handle -> IO a
+usage h = do
+ hPutStrLn h $ unlines
[ "Usage:"
, " propellor"
, " propellor hostname"
@@ -46,21 +46,21 @@ processCmdLine = go =<< getArgs
go ("--dump":f:c:[]) = withprivfield f c Dump
go ("--edit":f:c:[]) = withprivfield f c Edit
go ("--list-fields":[]) = return ListFields
- go ("--help":_) = usage
+ go ("--help":_) = usage stdout
go ("--update":h:[]) = return $ Update h
go ("--boot":h:[]) = return $ Update h -- for back-compat
go ("--continue":s:[]) = case readish s of
Just cmdline -> return $ Continue cmdline
Nothing -> errorMessage $ "--continue serialization failure (" ++ s ++ ")"
go (h:[])
- | "--" `isPrefixOf` h = usage
+ | "--" `isPrefixOf` h = usage stderr
| otherwise = return $ Run h
go [] = do
s <- takeWhile (/= '\n') <$> readProcess "hostname" ["-f"]
if null s
then errorMessage "Cannot determine hostname! Pass it on the command line."
else return $ Run s
- go _ = usage
+ go _ = usage stderr
withprivfield s c f = case readish s of
Just pf -> return $ f pf (Context c)