Skip to content

Fix typo (backport #9770) #10001

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions cabal-install/src/Distribution/Client/Setup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3362,6 +3362,73 @@ userConfigCommand =

-- ------------------------------------------------------------

-- * Dirs

-- ------------------------------------------------------------

-- | A path that can be retrieved by the @cabal path@ command.
data Path
= PathCacheDir
| PathLogsDir
| PathStoreDir
| PathConfigFile
| PathInstallDir
deriving (Eq, Ord, Show, Enum, Bounded)

-- | The configuration name for this path.
pathName :: Path -> String
pathName PathCacheDir = "cache-dir"
pathName PathLogsDir = "logs-dir"
pathName PathStoreDir = "store-dir"
pathName PathConfigFile = "config-file"
pathName PathInstallDir = "installdir"

data PathFlags = PathFlags
{ pathVerbosity :: Flag Verbosity
, pathDirs :: Flag [Path]
}
deriving (Generic)

instance Monoid PathFlags where
mempty =
PathFlags
{ pathVerbosity = toFlag normal
, pathDirs = toFlag []
}
mappend = (<>)

instance Semigroup PathFlags where
(<>) = gmappend

pathCommand :: CommandUI PathFlags
pathCommand =
CommandUI
{ commandName = "path"
, commandSynopsis = "Display paths used by cabal."
, commandDescription = Just $ \_ ->
wrapText $
"This command prints the directories that are used by cabal,"
++ " taking into account the contents of the configuration file and any"
++ " environment variables."
, commandNotes = Nothing
, commandUsage = \pname -> "Usage: " ++ pname ++ " path\n"
, commandDefaultFlags = mempty
, commandOptions = \_ ->
map pathOption [minBound .. maxBound]
++ [optionVerbosity pathVerbosity (\v flags -> flags{pathVerbosity = v})]
}
where
pathOption s =
option
[]
[pathName s]
("Print " <> pathName s)
pathDirs
(\v flags -> flags{pathDirs = Flag $ concat (flagToList (pathDirs flags) ++ flagToList v)})
(noArg (Flag [s]))

-- ------------------------------------------------------------

-- * GetOpt Utils

-- ------------------------------------------------------------
Expand Down
Loading