Commit ff38108c authored by Herbert Valerio Riedel's avatar Herbert Valerio Riedel 🕺
Browse files

Improve success message when `cabal upload`ing documentation

The message now reads like

    $ cabal upload -d dist/uhttpc-0.1.1.1-docs.tar.gz
    Uploading documentation dist/uhttpc-0.1.1.1-docs.tar.gz...
    Documentation successfully uploaded for package candidate. You can now preview
    the result at
    'https://hackage-origin.haskell.org/package/uhttpc-0.1.1.1/candidate'. To
    upload non-candidate documentation, use 'cabal upload --publish'.

while previously it read like

    $ cabal upload -d dist/uhttpc-0.1.1.1-docs.tar.gz
    Uploading documentation dist/uhttpc-0.1.1.1-docs.tar.gz...
    Ok

This improves usability as it gives a clear signal the docs have been
uploaded as candidate, and also on which URL you can see the result.

This implements the suggestion voiced in
https://github.com/haskell/cabal/issues/4777#issuecomment-330790520
parent e5f2754c
......@@ -102,6 +102,15 @@ uploadDoc verbosity repoCtxt mUsername mPassword isCandidate path = do
, "/docs"
]
}
packageUri = targetRepoURI {
uriPath = rootIfEmpty (uriPath targetRepoURI)
FilePath.Posix.</> concat
[ "package/", pkgid
, case isCandidate of
IsCandidate -> "/candidate"
IsPublished -> ""
]
}
(reverseSuffix, reversePkgid) = break (== '-')
(reverse (takeFileName path))
pkgid = reverse $ tail reversePkgid
......@@ -122,13 +131,23 @@ uploadDoc verbosity repoCtxt mUsername mPassword isCandidate path = do
-- Hackage responds with 204 No Content when docs are uploaded
-- successfully.
(code,_) | code `elem` [200,204] -> do
notice verbosity "Ok"
notice verbosity $ okMessage packageUri
(code,err) -> do
notice verbosity $ "Error uploading documentation "
++ path ++ ": "
++ "http code " ++ show code ++ "\n"
++ err
exitFailure
where
okMessage packageUri = case isCandidate of
IsCandidate ->
"Documentation successfully uploaded for package candidate. "
++ "You can now preview the result at '" ++ show packageUri
++ "'. To upload non-candidate documentation, use 'cabal upload --publish'."
IsPublished ->
"Package documentation successfully published. You can now view it at '"
++ show packageUri ++ "'."
promptUsername :: IO Username
promptUsername = do
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment