Skip to content

Commit

Permalink
Merge pull request #7710 from andreasabel/issue5410-help-unpack
Browse files Browse the repository at this point in the history
Fix #5410: include `unpack` in help text as deprecated alias for `get`
  • Loading branch information
mergify[bot] authored Oct 14, 2021
2 parents 69dbf54 + b88c365 commit 3f1a5f2
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 15 deletions.
2 changes: 1 addition & 1 deletion cabal-install/main/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ mainWorker args = do
, regularCmd infoCommand infoAction
, regularCmd fetchCommand fetchAction
, regularCmd getCommand getAction
, hiddenCmd unpackCommand unpackAction
, regularCmd unpackCommand unpackAction
, regularCmd checkCommand checkAction
, regularCmd uploadCommand uploadAction
, regularCmd reportCommand reportAction
Expand Down
47 changes: 33 additions & 14 deletions cabal-install/src/Distribution/Client/Setup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ globalCommand commands = CommandUI {
, "info"
, "user-config"
, "get"
, "unpack"
, "init"
, "configure"
, "build"
Expand Down Expand Up @@ -248,6 +249,7 @@ globalCommand commands = CommandUI {
, par
, startGroup "package"
, addCmd "get"
, addCmd "unpack"
, addCmd "init"
, par
, addCmd "configure"
Expand Down Expand Up @@ -1313,17 +1315,8 @@ getCommand :: CommandUI GetFlags
getCommand = CommandUI {
commandName = "get",
commandSynopsis = "Download/Extract a package's source code (repository).",
commandDescription = Just $ \_ -> wrapText $
"Creates a local copy of a package's source code. By default it gets "
++ "the source\ntarball and unpacks it in a local subdirectory. "
++ "Alternatively, with -s it will\nget the code from the source "
++ "repository specified by the package.\n",
commandNotes = Just $ \pname ->
"Examples:\n"
++ " " ++ pname ++ " get hlint\n"
++ " Download the latest stable version of hlint;\n"
++ " " ++ pname ++ " get lens --source-repository=head\n"
++ " Download the source repository (i.e. git clone from github).\n",
commandDescription = Just $ \_ -> wrapText $ unlines descriptionOfGetCommand,
commandNotes = Just $ \pname -> unlines $ notesOfGetCommand "get" pname,
commandUsage = usagePackages "get",
commandDefaultFlags = defaultGetFlags,
commandOptions = \_ -> [
Expand Down Expand Up @@ -1364,12 +1357,38 @@ getCommand = CommandUI {
]
}

-- | List of lines describing command @get@.
descriptionOfGetCommand :: [String]
descriptionOfGetCommand =
[ "Creates a local copy of a package's source code. By default it gets the source"
, "tarball and unpacks it in a local subdirectory. Alternatively, with -s it will"
, "get the code from the source repository specified by the package."
]

-- | Notes for the command @get@.
notesOfGetCommand
:: String -- ^ Either @"get"@ or @"unpack"@.
-> String -- ^ E.g. @"cabal"@.
-> [String] -- ^ List of lines.
notesOfGetCommand cmd pname =
[ "Examples:"
, " " ++ unwords [ pname, cmd, "hlint" ]
, " Download the latest stable version of hlint;"
, " " ++ unwords [ pname, cmd, "lens --source-repository=head" ]
, " Download the source repository of lens (i.e. git clone from github)."
]

-- 'cabal unpack' is a deprecated alias for 'cabal get'.
unpackCommand :: CommandUI GetFlags
unpackCommand = getCommand {
commandName = "unpack",
commandUsage = usagePackages "unpack"
unpackCommand = getCommand
{ commandName = "unpack"
, commandSynopsis = synopsis
, commandNotes = Just $ \ pname -> unlines $
notesOfGetCommand "unpack" pname
, commandUsage = usagePackages "unpack"
}
where
synopsis = "Deprecated alias for 'get'."

instance Monoid GetFlags where
mempty = gmempty
Expand Down

0 comments on commit 3f1a5f2

Please sign in to comment.