summaryrefslogtreecommitdiff
path: root/Main.hs
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 /Main.hs
parenta00b30a632206b312279ff85b3f9f9ec080dfb72 (diff)
downloadhurl-25589da5831b923918049bf7ca14c1497dd4e75f.tar.gz
hurl-25589da5831b923918049bf7ca14c1497dd4e75f.tar.bz2
hurl-25589da5831b923918049bf7ca14c1497dd4e75f.zip
Implement simple commandline version of HURL.
Diffstat (limited to 'Main.hs')
-rw-r--r--Main.hs19
1 files changed, 19 insertions, 0 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