Adding an option to cabal-install
Duncan Coutts
duncan.coutts at worc.ox.ac.uk
Mon Nov 26 21:02:25 EST 2007
On Sun, 2007-11-25 at 16:06 +0000, jim burton wrote:
> Hi, I was planning to make a small change to Fetch.hs to let it be used
> behind a proxy server, using the value of $http_proxy or $HTTP_PROXY
> where one of them exists -- hope that sounds OK?
Yes, that'd be great.
> This is easy to do, but so that windows users can benefit it would be
> good to make this an option read from the config file and/or opts and
> I'm having a much harder time working out how to do that.
Actually I'm just at the moment rewriting the way cabal-install handles
command line arguments.
> I tried to mimic the way other options work but can't get it working.
> Can you point out why? Several of the functions below aren't expected
> to work properly but should allow this line to be read
> from .cabal/conf:
>
> http_proxy:http://proxy.server.com:80
Ok, seems sensible. (We seem to be using a convention like .cabal files
with -'s in field names rather than _'s. It's only a minor consistency
nit.)
> But I get this:
>
> > $ ~/haskell/bin/cabal -v3 clean
> > Config file warning: Unrecognized stanza on line 5
> parseProxy :: ReadP r (Maybe ProxyInfo)
> parseProxy = do host <- munch1 (\c -> isAlphaNum c || c `elem` "_-.")
> char ':'
> port <- munch1 (\c -> isAlphaNum c)
> return $ Just (ProxyInfo host ((read port)::Int) Nothing
> Nothing)
So this doesn't work. It doesn't parse your example:
> readP_to_S parseProxy "http://proxy.server.com:80"
[]
Though this does work:
> readP_to_S parseProxy "proxy.server.com:80"
I would suggest not rewriting a parser for URIs and instead use the
standard Network.URI which provides a URI data type and a parser.
Duncan
More information about the cabal-devel
mailing list