better error message

This commit is contained in:
Joey Hess 2011-11-15 19:17:07 -04:00
parent 80a0be5116
commit 5c5ff2cb78

View file

@ -40,14 +40,17 @@ cmds = map adddirparam $ cmds_readonly ++ cmds_notreadonly
options :: [OptDescr (Annex ())] options :: [OptDescr (Annex ())]
options = commonOptions ++ options = commonOptions ++
[ Option [] ["uuid"] (ReqArg check paramUUID) "repository uuid" [ Option [] ["uuid"] (ReqArg checkuuid paramUUID) "repository uuid"
] ]
where where
check expected = do checkuuid expected = getUUID >>= check
u <- getUUID where
when (u /= toUUID expected) $ error $ check u | u == toUUID expected = return ()
"expected repository UUID " ++ expected check NoUUID = unexpected "uninitialized repository"
++ " but found UUID " ++ fromUUID u check u = unexpected $ "UUID " ++ fromUUID u
unexpected s = error $
"expected repository UUID " ++
expected ++ " but found " ++ s
header :: String header :: String
header = "Usage: git-annex-shell [-c] command [parameters ...] [option ..]" header = "Usage: git-annex-shell [-c] command [parameters ...] [option ..]"