From 25589da5831b923918049bf7ca14c1497dd4e75f Mon Sep 17 00:00:00 2001 From: Adrian Cochrane Date: Sat, 18 Apr 2020 09:21:54 +1200 Subject: [PATCH] Implement simple commandline version of HURL. --- Main.hs | 19 +++++++++++++++++++ hurl.cabal | 4 ++-- src/Main.hs | 5 ----- 3 files changed, 21 insertions(+), 7 deletions(-) create mode 100644 Main.hs delete mode 100644 src/Main.hs 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!" -- 2.30.2