diff --git a/app/ghcup/GHCup/OptParse/Common.hs b/app/ghcup/GHCup/OptParse/Common.hs index e4f7ca968b3f6bb26f0908b10c708862f631ccb9..cbe4cbc0391c3e040e78f80233ed476b2b3be75e 100644 --- a/app/ghcup/GHCup/OptParse/Common.hs +++ b/app/ghcup/GHCup/OptParse/Common.hs @@ -302,14 +302,17 @@ gpgParser s' | t == T.pack "strict" = Right GPGStrict toolCompleter :: Completer toolCompleter = listCompleter ["ghc", "cabal", "hls", "stack"] +gitFileUri :: [String] -> Completer +gitFileUri add = mkCompleter $ fileUri' (["git://"] <> add) + fileUri :: Completer -fileUri = mkCompleter fileUri' +fileUri = mkCompleter $ fileUri' [] -fileUri' :: String -> IO [String] -fileUri' = \case +fileUri' :: [String] -> String -> IO [String] +fileUri' add = \case "" -> do pwd <- getCurrentDirectory - pure ["https://", "http://", "file:///", "file://" <> pwd <> "/"] + pure $ ["https://", "http://", "file:///", "file://" <> pwd <> "/"] <> add xs | "file:///" `isPrefixOf` xs -> fmap ("file://" <>) <$> case stripPrefix "file://" xs of @@ -476,7 +479,7 @@ toolDlCompleter :: Tool -> Completer toolDlCompleter tool = mkCompleter $ \case "" -> pure (initUrl tool <> ["https://", "http://", "file:///"]) word - | "file://" `isPrefixOf` word -> fileUri' word + | "file://" `isPrefixOf` word -> fileUri' [] word -- downloads.haskell.org | "https://downloads.haskell.org/" `isPrefixOf` word -> fmap (completePrefix word) . prefixMatch (FP.takeFileName word) <$> fromHRef word diff --git a/app/ghcup/GHCup/OptParse/Compile.hs b/app/ghcup/GHCup/OptParse/Compile.hs index 4ee0f7cf32b08d0329d9a36af12e59741be9fb72..67da67080244cf329d4a51df28fb608a776b21df 100644 --- a/app/ghcup/GHCup/OptParse/Compile.hs +++ b/app/ghcup/GHCup/OptParse/Compile.hs @@ -173,7 +173,10 @@ ghcCompileOpts = (short 'g' <> long "git-ref" <> metavar "GIT_REFERENCE" <> help "The git commit/branch/ref to build from" ) <*> - optional (option str (short 'r' <> long "repository" <> metavar "GIT_REPOSITORY" <> help "The git repository to build from (defaults to GHC upstream)")) + optional (option str ( + short 'r' <> long "repository" <> metavar "GIT_REPOSITORY" <> help "The git repository to build from (defaults to GHC upstream)" + <> completer (gitFileUri ["https://gitlab.haskell.org/ghc/ghc.git"]) + )) ))) <*> option (eitherReader @@ -285,7 +288,9 @@ hlsCompileOpts = (short 'g' <> long "git-ref" <> metavar "GIT_REFERENCE" <> help "The git commit/branch/ref to build from" ) <*> - optional (option str (short 'r' <> long "repository" <> metavar "GIT_REPOSITORY" <> help "The git repository to build from (defaults to GHC upstream)")) + optional (option str (short 'r' <> long "repository" <> metavar "GIT_REPOSITORY" <> help "The git repository to build from (defaults to GHC upstream)" + <> completer (gitFileUri ["https://github.com/haskell/haskell-language-server.git"]) + )) ))) <*> optional (option