Skip to content

Commit 2104dc5

Browse files
committed
Make --relocatable accept a path
1 parent ecb4b9f commit 2104dc5

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

docs/Install.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ Run `hoogle generate --local=mydir1 --local=mydir2` to generate an index for the
3131

3232
### Index a directory, producing a relocatable database
3333

34-
Run `hoogle generate --relocatable --local=mydir` to generate an index that supports moving the Haddock directory to a different path without breaking the Haddock links.
35-
This mode only supports one `--local` directory.
34+
Run `hoogle generate --relocatable=mydir` to generate an index that supports moving the Haddock directory to a different path without breaking the Haddock links.
35+
This mode acts like `--local` but only supports one directory.
3636

3737
## Searching a Hoogle database
3838

src/Action/CmdLine.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ data CmdLine
4545
,haddock :: Maybe FilePath
4646
,debug :: Bool
4747
,language :: Language
48-
,relocatable :: Bool
48+
,relocatable :: Maybe FilePath
4949
}
5050
| Server
5151
{port :: Int
@@ -152,7 +152,7 @@ generate = Generate
152152
,count = Nothing &= name "n" &= help "Maximum number of packages to index (defaults to all)"
153153
,haddock = def &= help "Use local haddocks"
154154
,debug = def &= help "Generate debug information"
155-
,relocatable = False &= help "Generate a relocatable database"
155+
,relocatable = Nothing &= help "Index local packages and link to local haddock docs, producing a relocatable database"
156156
} &= help "Generate Hoogle databases"
157157

158158
server = Server

src/Action/Generate.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -246,17 +246,17 @@ actionGenerate g@Generate{..} = withTiming (if debug then Just $ replaceExtensio
246246
Haskell | Just dir <- haddock -> do
247247
warnFlagIgnored "--haddock" "set" (local_ /= []) "--local"
248248
warnFlagIgnored "--haddock" "set" (isJust download) "--download"
249-
warnFlagIgnored "--haddock" "set" relocatable "--relocatable"
249+
warnFlagIgnored "--haddock" "set" (isJust relocatable) "--relocatable"
250250
readHaskellHaddock timing settings dir
251251
| [""] <- local_ -> do
252252
warnFlagIgnored "--local" "used as flag (no paths)" (isJust download) "--download"
253253
readHaskellGhcpkg timing settings
254+
| Just _ <- relocatable, _:_ <- local_ ->
255+
exitFail "Error: --relocatable and --local are mutually exclusive"
256+
| Just relocatable' <- relocatable -> do
257+
prefix <- traverse canonicalizePath relocatable
258+
readHaskellDirs timing settings prefix [relocatable']
254259
| [] <- local_ -> do readHaskellOnline timing settings doDownload
255-
| relocatable, _:_:_ <- local_ ->
256-
exitFail "Error: --relocatable needs exactly one --local, or the paths will be ambiguous"
257-
| relocatable -> do
258-
prefix <- traverse canonicalizePath $ listToMaybe local_
259-
readHaskellDirs timing settings prefix local_
260260
| otherwise -> readHaskellDirs timing settings Nothing local_
261261
Frege | [] <- local_ -> readFregeOnline timing doDownload
262262
| otherwise -> errorIO "No support for local Frege databases"

0 commit comments

Comments
 (0)