Add option to specify cabal-dev sandbox explicitly.
This commit is contained in:
parent
cdd8eb71a3
commit
b0cabae366
14
CabalDev.hs
14
CabalDev.hs
@ -17,11 +17,19 @@ import Types
|
|||||||
modifyOptions :: Options -> IO Options
|
modifyOptions :: Options -> IO Options
|
||||||
modifyOptions opts = found ||> notFound
|
modifyOptions opts = found ||> notFound
|
||||||
where
|
where
|
||||||
found = addPath opts <$> findCabalDev
|
found = do
|
||||||
|
path <- findCabalDev (sandbox opts)
|
||||||
|
return $ addPath opts path
|
||||||
notFound = return opts
|
notFound = return opts
|
||||||
|
|
||||||
findCabalDev :: IO String
|
findCabalDev :: Maybe String -> IO FilePath
|
||||||
findCabalDev = getCurrentDirectory >>= searchIt . splitPath
|
findCabalDev (Just path) = do
|
||||||
|
a <- doesDirectoryExist path
|
||||||
|
if a then
|
||||||
|
findConf path
|
||||||
|
else
|
||||||
|
findCabalDev Nothing
|
||||||
|
findCabalDev Nothing = getCurrentDirectory >>= searchIt . splitPath
|
||||||
|
|
||||||
addPath :: Options -> String -> Options
|
addPath :: Options -> String -> Options
|
||||||
addPath orig_opts path = do
|
addPath orig_opts path = do
|
||||||
|
@ -57,6 +57,9 @@ argspec = [ Option "l" ["tolisp"]
|
|||||||
, Option "o" ["operators"]
|
, Option "o" ["operators"]
|
||||||
(NoArg (\opts -> opts { operators = True }))
|
(NoArg (\opts -> opts { operators = True }))
|
||||||
"print operators, too"
|
"print operators, too"
|
||||||
|
, Option "s" ["sandbox"]
|
||||||
|
(ReqArg (\s opts -> opts { sandbox = Just s }) "path")
|
||||||
|
"specify cabal-dev sandbox (default 'cabal-dev`)"
|
||||||
]
|
]
|
||||||
|
|
||||||
parseArgs :: [OptDescr (Options -> Options)] -> [String] -> (Options, [String])
|
parseArgs :: [OptDescr (Options -> Options)] -> [String] -> (Options, [String])
|
||||||
|
2
Types.hs
2
Types.hs
@ -10,6 +10,7 @@ data Options = Options {
|
|||||||
, ghcOpts :: [String]
|
, ghcOpts :: [String]
|
||||||
, operators :: Bool
|
, operators :: Bool
|
||||||
, expandSplice :: Bool
|
, expandSplice :: Bool
|
||||||
|
, sandbox :: Maybe String
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultOptions :: Options
|
defaultOptions :: Options
|
||||||
@ -19,6 +20,7 @@ defaultOptions = Options {
|
|||||||
, ghcOpts = []
|
, ghcOpts = []
|
||||||
, operators = False
|
, operators = False
|
||||||
, expandSplice = False
|
, expandSplice = False
|
||||||
|
, sandbox = Nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
----------------------------------------------------------------
|
----------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user