summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Cochrane <adrian@openwork.nz>2020-04-18 09:21:54 +1200
committerAdrian Cochrane <adrian@openwork.nz>2020-04-18 09:21:54 +1200
commit25589da5831b923918049bf7ca14c1497dd4e75f (patch)
treee00f9d8c1be23d3025e8f60d1cf3c82fc8a81a38
parenta00b30a632206b312279ff85b3f9f9ec080dfb72 (diff)
downloadhurl-25589da5831b923918049bf7ca14c1497dd4e75f.tar.gz
hurl-25589da5831b923918049bf7ca14c1497dd4e75f.tar.bz2
hurl-25589da5831b923918049bf7ca14c1497dd4e75f.zip
Implement simple commandline version of HURL.
-rw-r--r--Main.hs19
-rw-r--r--hurl.cabal4
-rw-r--r--src/Main.hs5
3 files changed, 21 insertions, 7 deletions
diff --git a/Main.hs b/Main.hs
new file mode 100644
index 0000000..270bd65
--- /dev/null
+++ b/Main.hs
@@ -0,0 +1,19 @@
+module Main where
+
+import Network.URI.Fetch
+-- Input parsing
+import System.Environment (getArgs)
+import Network.URI (parseURI, nullURI)
+import Data.Maybe (catMaybes)
+-- Where to save files
+import System.Directory (getCurrentDirectory)
+
+main :: IO ()
+main = do
+ urls <- getArgs
+ let urls' = catMaybes $ map parseURI urls
+ session <- newSession
+ dir <- getCurrentDirectory
+
+ res <- fetchURLs session ["*/*"] urls' $ saveDownload nullURI dir
+ putStrLn $ show res
diff --git a/hurl.cabal b/hurl.cabal
index 94917b2..edc1569 100644
--- a/hurl.cabal
+++ b/hurl.cabal
@@ -129,10 +129,10 @@ executable hurl
main-is: Main.hs
-- Other library packages from which modules are imported
- build-depends: base >=4.9 && <=4.12, hurl
+ build-depends: base >=4.9 && <=4.12, hurl, network-uri, directory
-- Directories containing source files.
- hs-source-dirs: src
+ hs-source-dirs: .
-- Base language which the package is written in.
default-language: Haskell2010
diff --git a/src/Main.hs b/src/Main.hs
deleted file mode 100644
index 5105a9b..0000000
--- a/src/Main.hs
+++ /dev/null
@@ -1,5 +0,0 @@
-module Main where
-
-main :: IO ()
-main = do
- putStrLn "Hello, world!"