packages feed

rob 0.0.3 → 0.0.4

raw patch · 2 files changed

+22/−19 lines, 2 filesdep ~Globdep ~bytestringdep ~directory

Dependency ranges changed: Glob, bytestring, directory, ede, filepath, fortytwo, text, time, unordered-containers, vector

Files

rob.cabal view
@@ -1,5 +1,5 @@ name:                rob-version:0.0.3+version:0.0.4 synopsis:            Simple projects generator description:         See README at <https://github.com/GianlucaGuarini/rob/blob/develop/README.md> homepage:            https://github.com/gianlucaguarini/rob#readme@@ -28,20 +28,20 @@                        Rob.Actions.List,                        Rob.Actions.Add   build-depends:       base >= 4.7 && < 5,-                       fortytwo <= 1.0.2,-                       directory <= 1.3.0.0,-                       filepath <= 1.4.1.2,+                       fortytwo <= 1.0.5,+                       directory <= 1.3.3.2,+                       filepath <= 1.4.2.1,                        pathwalk <= 0.3.1.2,-                       Glob <= 0.9.1,+                       Glob <= 0.10.0,                        yaml <= 0.11.0.0,-                       vector <= 0.12.0.1,-                       ede == 0.2.8.7,-                       text <= 1.2.2.2,-                       unordered-containers <= 0.2.8.0,+                       vector == 0.12.0.2,+                       ede == 0.2.9,+                       text <= 1.2.3.1,+                       unordered-containers <= 0.2.9.0,                        cmdargs >= 0.10.17 && <= 0.10.20,                        ansi-terminal <= 0.8.2,-                       bytestring <= 0.10.8.1,-                       time <= 1.6.0.1+                       bytestring <= 0.10.8.2,+                       time <= 1.8.0.2   other-modules:       Paths_rob   default-language:    Haskell2010 
src/Rob/Config.hs view
@@ -9,7 +9,7 @@ import System.Exit import System.FilePath (joinPath) import System.Directory (getHomeDirectory, doesFileExist)-import Data.Yaml (encodeFile, decodeFile)+import Data.Yaml (encodeFile, decodeFileEither)  -- | Get the config file name configFileName :: String@@ -22,11 +22,15 @@   return $ joinPath [home, configFileName]  -- | Write the config file and return it-write :: Config -> IO Config-write config = do+writeConfig :: Config -> IO Config+writeConfig config = do   configFilePath >>= \path -> encodeFile path config   return config +-- | Read the config file and return it+readConfig :: FilePath -> IO Config+readConfig path = either (error . show) id <$> decodeFileEither path+ -- | Get the current Config file Data -- | If it doesn't exist it will create a new one get :: IO Config@@ -36,13 +40,12 @@   if hasConfigPath     then do       success $ configFileFound path-      config <- decodeFile path-      return $ fromJust config+      readConfig path     else do       warning $ noConfigFileFound configFileName       flatten info $ configFileCreated path       -- return an empty Config object and write it in the home directory-      write $ Config []+      writeConfig $ Config []  -- | Dispatch the no templates available error errorNoTemplatesAvailable :: IO ()@@ -53,7 +56,7 @@  -- | Add a new template to the config object and write it addTemplate :: Config -> String -> String -> IO Config-addTemplate (Config templates) name path = write $ Config newTemplates+addTemplate (Config templates) name path = writeConfig $ Config newTemplates   where     newTemplate = Template name path     newTemplates = if newTemplate `elem` templates then@@ -63,6 +66,6 @@  -- | Delete a template from the list of templates deleteTemplate :: Config -> String -> IO Config-deleteTemplate (Config templates) nameToRemove = write $ Config newTemplates+deleteTemplate (Config templates) nameToRemove = writeConfig $ Config newTemplates   where     newTemplates = (\(Template name _) -> name /= nameToRemove) `filter` templates