From 332dbf7b9b79f9cb2fa60212cc5529e0c490c1de Mon Sep 17 00:00:00 2001 From: krasimir Date: Mon, 5 Oct 2009 14:58:13 +0000 Subject: another attempt to get the paths handling right --- src/GF/Infra/Option.hs | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) (limited to 'src/GF/Infra/Option.hs') diff --git a/src/GF/Infra/Option.hs b/src/GF/Infra/Option.hs index fc5ddf87c..8c3d4d267 100644 --- a/src/GF/Infra/Option.hs +++ b/src/GF/Infra/Option.hs @@ -186,18 +186,28 @@ instance Show Options where -- Option parsing -parseOptions :: [String] -> Err (Options, [FilePath]) -parseOptions args - | not (null errs) = errors errs - | otherwise = do opts <- liftM concatOptions $ sequence optss - return (opts, files) - where (optss, files, errs) = getOpt RequireOrder optDescr args - -parseModuleOptions :: [String] -> Err Options -parseModuleOptions args = do (opts,nonopts) <- parseOptions args - if null nonopts - then return opts - else errors $ map ("Non-option among module options: " ++) nonopts +parseOptions :: FilePath -- ^ if there are relative file paths they will be interpreted as relative to this path + -> [String] -- ^ list of string arguments + -> Err (Options, [FilePath]) +parseOptions root args + | not (null errs) = errors errs + | otherwise = do opts <- liftM concatOptions $ sequence optss + return (fixRelativeLibPaths opts, files) + where + (optss, files, errs) = getOpt RequireOrder optDescr args + + fixRelativeLibPaths (Options o) = Options (fixPathFlags . o) + where + fixPathFlags f@(Flags{optLibraryPath=path}) = f{optLibraryPath=map (root ) path} + +parseModuleOptions :: FilePath -- ^ if there are relative file paths they will be interpreted as relative to this path + -> [String] -- ^ list of string arguments + -> Err Options +parseModuleOptions root args = do + (opts,nonopts) <- parseOptions root args + if null nonopts + then return opts + else errors $ map ("Non-option among module options: " ++) nonopts -- Showing options -- cgit v1.2.3