diff --git a/src/Arguments.hs b/src/Arguments.hs index 8062483..2b2e900 100644 --- a/src/Arguments.hs +++ b/src/Arguments.hs @@ -6,6 +6,8 @@ module Arguments ( import Data.Monoid ((<>)) import Options.Applicative +import System.Directory (doesDirectoryExist, makeAbsolute) +import System.Exit (die) import System.FilePath.Posix (dropTrailingPathSeparator, isValid) data Arguments = Arguments { @@ -39,8 +41,11 @@ directory = eitherReader $ \path -> else Left "This string doesn't represent a valid path" configuration :: IO Arguments -configuration = - execParser $ - info (arguments <**> helper) - ( fullDesc - ) +configuration = do + inputArguments <- execParser $ info (arguments <**> helper) fullDesc + directoryExists <- doesDirectoryExist $ sourceDir inputArguments + if directoryExists + then do + absolutePath <- makeAbsolute $ sourceDir inputArguments + return $ inputArguments { sourceDir = absolutePath } + else die "INPUT_DIR doesn't exist"