Skip to content

Commit

Permalink
Resolve #6809: v2-update supports -z
Browse files Browse the repository at this point in the history
  • Loading branch information
phadej committed May 18, 2020
1 parent 02859ae commit a4c0be0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
24 changes: 16 additions & 8 deletions cabal-install/Distribution/Client/CmdUpdate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ import Distribution.Client.ProjectConfig
( ProjectConfig(..)
, ProjectConfigShared(projectConfigConfigFile)
, projectConfigWithSolverRepoContext
, withProjectOrGlobalConfig )
, withProjectOrGlobalConfigIgn )
import Distribution.Client.ProjectFlags
( ProjectFlags (..), defaultProjectFlags, projectFlagsOptions )
import Distribution.Client.Types
( Repo(..), RepoName (..), unRepoName, RemoteRepo(..), isRepoRemote )
import Distribution.Client.HttpUtils
Expand Down Expand Up @@ -61,11 +63,11 @@ import Distribution.Client.GZipUtils (maybeDecompress)
import System.FilePath ((<.>), dropExtension)
import Data.Time (getCurrentTime)
import Distribution.Simple.Command
( CommandUI(..), usageAlternatives )
( CommandUI(..), usageAlternatives, optionName )

import qualified Hackage.Security.Client as Sec

updateCommand :: CommandUI (NixStyleFlags ())
updateCommand :: CommandUI (NixStyleFlags ProjectFlags)
updateCommand = CommandUI
{ commandName = "v2-update"
, commandSynopsis = "Updates list of known packages."
Expand Down Expand Up @@ -96,8 +98,12 @@ updateCommand = CommandUI
++ "https://github.com/haskell/cabal/issues and if you\nhave any time "
++ "to get involved and help with testing, fixing bugs etc then\nthat "
++ "is very much appreciated.\n"
, commandOptions = nixStyleOptions (const []) -- clientInstallOptions
, commandDefaultFlags = defaultNixStyleFlags () -- defaultClientInstallFlags
-- TODO: Add ProjectFlags to NixStyleFlags,
-- so project-file won't be ambiguous
, commandOptions = nixStyleOptions $ const
$ filter (\o -> optionName o `notElem` ["project-file"])
$ projectFlagsOptions
, commandDefaultFlags = defaultNixStyleFlags defaultProjectFlags
}

data UpdateRequest = UpdateRequest
Expand All @@ -114,9 +120,11 @@ instance Parsec UpdateRequest where
state <- P.char ',' *> parsec <|> pure IndexStateHead
return (UpdateRequest name state)

updateAction :: NixStyleFlags () -> [String] -> GlobalFlags -> IO ()
updateAction NixStyleFlags {..} extraArgs globalFlags = do
projectConfig <- withProjectOrGlobalConfig verbosity globalConfigFlag
updateAction :: NixStyleFlags ProjectFlags -> [String] -> GlobalFlags -> IO ()
updateAction NixStyleFlags { extraFlags = projectFlags, ..} extraArgs globalFlags = do
let ignoreProject = fromFlagOrDefault False (flagIgnoreProject projectFlags)

projectConfig <- withProjectOrGlobalConfigIgn ignoreProject verbosity globalConfigFlag
(projectConfig <$> establishProjectBaseContext verbosity cliConfig OtherCommand)
(\globalConfig -> return $ globalConfig <> cliConfig)

Expand Down
1 change: 1 addition & 0 deletions cabal-install/Distribution/Client/ProjectFlags.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ data ProjectFlags = ProjectFlags
{ flagProjectFileName :: Flag FilePath
, flagIgnoreProject :: Flag Bool
}
deriving (Show)

defaultProjectFlags :: ProjectFlags
defaultProjectFlags = ProjectFlags
Expand Down

0 comments on commit a4c0be0

Please sign in to comment.