herms 1.9.0.2 → 1.9.0.3
raw patch · 3 files changed
+34/−10 lines, 3 filesdep ~brickdep ~mtldep ~vty
Dependency ranges changed: brick, mtl, vty
Files
- app/herms.hs +22/−6
- herms.cabal +5/−4
- src/AddFile.hs +7/−0
app/herms.hs view
@@ -18,6 +18,7 @@ import Text.Read import Utils import AddCLI+import AddFile import RichText import Types import UnitConversions@@ -30,7 +31,7 @@ -- Global constants versionStr :: String-versionStr = "1.9.0.2"+versionStr = "1.9.0.3" configPath :: IO FilePath configPath = getDataFileName "config.hs"@@ -75,12 +76,22 @@ liftIO $ putStrLn ("\n" ++ (t Str.badEntry) ++ "\n") saveOrDiscard input oldRecp -add :: HermsReader IO ()-add = do+addInteractive :: HermsReader IO ()+addInteractive = do (config, recipeBook) <- ask input <- liftIO $ getAddInput (translator config) saveOrDiscard input Nothing ++add :: [String] -> HermsReader IO ()+add [] = addInteractive+add filenames = do+ (config, recipeBook) <- ask+ forM_ filenames $ \ filename -> do+ contents <- liftIO $ readFile filename+ saveOrDiscard (readRecipeFileData contents) Nothing+ + doEdit :: Recipe -> Maybe Recipe -> HermsReader IO () doEdit recp origRecp = do (config, recipeBook) <- ask@@ -325,7 +336,7 @@ -- @runWithOpts runs the action of selected command. runWithOpts :: Command -> HermsReader IO () runWithOpts (List tags group nameOnly) = list tags group nameOnly-runWithOpts Add = add+runWithOpts (Add targets) = add targets runWithOpts (Edit target) = edit target runWithOpts (Import target) = importFile target runWithOpts (Export targets) = export targets@@ -344,7 +355,7 @@ -- | 'Command' data type represents commands of CLI data Command = List [String] Bool Bool -- ^ shows recipes | View [String] Int Bool String -- ^ shows specified recipes with given serving- | Add -- ^ adds the recipe (interactively)+ | Add [String] -- ^ adds the recipe (interactively or from files) | Edit String -- ^ edits the recipe | Import String -- ^ imports a recipe file | Export [String] -- ^ exports recipes to stdout@@ -354,7 +365,7 @@ listP, addP, viewP, editP, importP, exportP, shopP, dataDirP :: Translator -> Parser Command listP t = List <$> (words <$> (tagsP t)) <*> (groupByTagsP t) <*> (nameOnlyP t)-addP _ = pure Add+addP t = Add <$> (severalFilesP t) editP t = Edit <$> (recipeNameP t) importP t = Import <$> (fileNameP t) exportP t = Export <$> (severalRecipesP t)@@ -413,6 +424,11 @@ fileNameP :: Translator -> Parser String fileNameP t = strArgument ( metavar (t Str.fileNameMetavar) <> help (t Str.fileNameDesc))++-- | @severalFilesP parses several file names at once+-- and returns th parser of a list of names+severalFilesP :: Translator -> Parser [String]+severalFilesP t = many (fileNameP t) -- | @severalRecipesP parses several recipe names at once -- and returns the parser of list of names
herms.cabal view
@@ -16,7 +16,7 @@ -- PVP summary: +-+------- New features or improvements with significant API change -- | | +----- Bugfixes and improvements with minor change to API -- | | | +--- Bugfixes and improvements with no change to API-version: 1.9.0.2+version: 1.9.0.3 -- A short (one-line) description of the package. synopsis: A command-line manager for delicious kitchen recipes@@ -68,6 +68,7 @@ -- Modules included in this executable, other than Main. other-modules: Utils , AddCLI+ , AddFile , RichText , ReadConfig , Types@@ -84,15 +85,15 @@ -- Other library packages from which modules are imported. build-depends: ansi-terminal >= 0.7.0 && <= 0.8.1 , base >=4.8 && <5- , brick >= 0.19 && < 0.38+ , brick >= 0.19 && <= 0.38 , directory >= 0.0 , microlens >=0.4 && <0.5 , microlens-th >=0.4 && <0.5- , mtl >= 2.2.1 && <= 2.2.2+ , mtl >= 2.2.1 && < 2.3 , optparse-applicative >=0.14 && <0.15 , semigroups >= 0.18.3 && < 0.19 , split >=0.2 && <0.3- , vty >=5.15 && < 5.22+ , vty >=5.15 && <= 5.22 -- Directories containing source files.
+ src/AddFile.hs view
@@ -0,0 +1,7 @@+module AddFile where++import UnitConversions++readRecipeFileData :: String -> [[String]]+readRecipeFileData _ = [["Nazzzme"],["Des lol","djdj",""],["2"],["2","1 2/2"],["units","units"],["name","name2"],["lol","ehe"],["jejej","ejeje","kks","lslsl","slsl"],["spicy licy lol"]]+