summaryrefslogtreecommitdiff
path: root/CmdLine.hs
diff options
context:
space:
mode:
authorJoey Hess <joey@kitenet.net>2014-03-30 23:02:10 -0400
committerJoey Hess <joey@kitenet.net>2014-03-30 23:02:10 -0400
commit02a7bf5f0e2de1d0dea71781ed0c1ae3a50e6425 (patch)
tree7900cf0f30f2d27b9d79ae6fc561b79dc308feaa /CmdLine.hs
parent647e1a6de21176625e1844c6b3838ffca8dca70e (diff)
tweak
Diffstat (limited to 'CmdLine.hs')
-rw-r--r--CmdLine.hs12
1 files changed, 9 insertions, 3 deletions
diff --git a/CmdLine.hs b/CmdLine.hs
index a4ef3bae..c93d69ad 100644
--- a/CmdLine.hs
+++ b/CmdLine.hs
@@ -41,14 +41,20 @@ usage = do
]
exitFailure
-defaultMain :: (HostName -> [Property]) -> IO ()
+defaultMain :: (HostName -> Maybe [Property]) -> IO ()
defaultMain getprops = go =<< processCmdLine
where
- go (Run host) = ensureProperties (getprops host)
+ go (Run host) = maybe (unknownhost host) ensureProperties (getprops host)
go (Spin host) = spin host
- go (Boot host) = boot (getprops host)
+ go (Boot host) = maybe (unknownhost host) boot (getprops host)
go (Set host field) = setPrivData host field
+unknownhost :: HostName -> IO a
+unknownhost h = error $ unwords
+ [ "Unknown host:", h
+ , "(perhaps you should specify the real hostname on the command line?)"
+ ]
+
spin :: HostName -> IO ()
spin host = do
url <- getUrl