aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoris2015-08-30 21:39:25 +0200
committerJoris2015-08-30 21:39:25 +0200
commit779e58b150aacd2d4eb50a7ec761bb9454499b6f (patch)
tree3c355d823013d96f5eb0072330e63a829ee7a9a8
parent5ca62f8fffce22944119b684c1cbb0ca476eecf5 (diff)
Generate csv files in the output directory
-rw-r--r--.gitignore1
-rw-r--r--README.md2
-rw-r--r--perfume.cabal1
-rw-r--r--src/Main.hs9
4 files changed, 10 insertions, 3 deletions
diff --git a/.gitignore b/.gitignore
index f06235c..526cb6a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
node_modules
dist
+output
diff --git a/README.md b/README.md
index 50ba178..c847c52 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
# Perfumes
-Get perfumes with the same materials.
+Get perfumes with the same materials thanks to data from http://olfatheque.com.
## Usage
diff --git a/perfume.cabal b/perfume.cabal
index 7f5c8e6..f096a35 100644
--- a/perfume.cabal
+++ b/perfume.cabal
@@ -17,3 +17,4 @@ executable perfume
, lens == 4.12.3
, aeson == 0.9.0.1
, utf8-string == 1.0.1.1
+ , directory == 1.2.3.1
diff --git a/src/Main.hs b/src/Main.hs
index cf557a0..f758ef7 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -7,6 +7,7 @@ module Main
import HTTP
import System.Environment (getArgs, getProgName)
+import System.Directory (createDirectory)
import Data.List (intercalate)
import Data.Text (Text)
@@ -35,8 +36,12 @@ main = do
T.putStrLn error
Right perfumesSequences ->
let commonPerfumes = getCommonPerfumes perfumesSequences
- outputName = (intercalate "-" materials) ++ ".csv"
- in T.writeFile outputName (csvPerfumes commonPerfumes)
+ outputDirectory = "output"
+ outputName = outputDirectory ++ "/" ++ (intercalate "-" materials) ++ ".csv"
+ in do
+ createDirectory outputDirectory
+ T.writeFile outputName (csvPerfumes commonPerfumes)
+ putStrLn ("Successfully generated " ++ outputName)
getHtmlPerfumes :: Text -> IO (Either Text [Perfume])
getHtmlPerfumes material = do