diff options
author | Brad Richardson <brichardson@structint.com> | 2020-03-31 15:12:50 -0500 |
---|---|---|
committer | Brad Richardson <brichardson@structint.com> | 2020-03-31 15:12:50 -0500 |
commit | 43b28f9559cb4cb3affb1bee7063bf27399c7b31 (patch) | |
tree | 132ac41c7e4a3189cea4c629c48855114d9cd17a /app | |
parent | cff70a2c97d26e64c65c391ec2121df90196b6cd (diff) | |
download | fpm-43b28f9559cb4cb3affb1bee7063bf27399c7b31.tar.gz fpm-43b28f9559cb4cb3affb1bee7063bf27399c7b31.zip |
Add default for library settings
Diffstat (limited to 'app')
-rw-r--r-- | app/Main.hs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/app/Main.hs b/app/Main.hs index 974c7a6..8d07c40 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -25,6 +25,7 @@ import Options.Applicative ( Parser , progDesc , subparser ) +import System.Directory ( doesDirectoryExist ) import Toml ( TomlCodec , (.=) ) @@ -147,9 +148,19 @@ libraryCodec = Library <$> Toml.text "source-dir" .= librarySourceDir toml2AppSettings :: TomlSettings -> IO AppSettings toml2AppSettings tomlSettings = do + librarySettings <- getLibrarySettings $ tomlSettingsLibrary tomlSettings return AppSettings { appSettingsCompiler = tomlSettingsCompiler tomlSettings , appSettingsProjectName = tomlSettingsProjectName tomlSettings , appSettingsDebugOptions = tomlSettingsDebugOptions tomlSettings - , appSettingsLibrary = tomlSettingsLibrary tomlSettings + , appSettingsLibrary = librarySettings } + +getLibrarySettings :: Maybe Library -> IO (Maybe Library) +getLibrarySettings maybeSettings = case maybeSettings of + Just settings -> return maybeSettings + Nothing -> do + defaultExists <- doesDirectoryExist "src" + if defaultExists + then return (Just (Library { librarySourceDir = "src" })) + else return Nothing |