diff --git a/flake.nix b/flake.nix index d04dcad05bc4ae044d5beb0ccc2029fbc2b687ce..28d1100a3d0f0f5fbf2689736b0d8834fc12f3b5 100644 --- a/flake.nix +++ b/flake.nix @@ -70,6 +70,23 @@ }; packages = hslib.packages {}; apps.hlint = hslib.apps.hlint {}; + apps.entr-test = { + type = "app"; + program = "${ + pkgs.writeShellApplication { + name = "entr-test"; + runtimeInputs = with pkgs; [ + entr + cabal-install + haskell.compiler.${ghcVersion} + ]; + + text = '' + find . -iname '*.hs' -or -iname '*.cabal' | entr bash -c "cabal run tests; if [ \$? != 0 ]; then printf '\e[31m%s\e[0m\n' \"FAILED: \$?\"; else printf '\e[32m%s\e[0m\n' 'SUCCESS'; fi" + ''; + } + }/bin/entr-test"; + }; # Using the working directory of `nix run`, do a build with cabal and # then run the test suite. diff --git a/gbs-downloader.cabal b/gbs-downloader.cabal index 5b79beb1da8cc4ba249423f856ab5a382f9efb8d..974cad6d5a24d7f6acb48f53491223146d2e1530 100644 --- a/gbs-downloader.cabal +++ b/gbs-downloader.cabal @@ -122,7 +122,7 @@ library -- Base language which the package is written in. default-language: Haskell2010 -executable gbs-download-chk +executable download-chk -- Import common warning flags. import: warnings @@ -155,7 +155,7 @@ executable gbs-download-chk -- Base language which the package is written in. default-language: Haskell2010 -executable gbs-download-sdmf +executable download-sdmf import: warnings , language @@ -175,6 +175,28 @@ executable gbs-download-sdmf hs-source-dirs: download-sdmf default-language: Haskell2010 +executable list-dircap + import: + warnings + , language + + main-is: Main.hs + build-depends: + , aeson + , base + , bytestring + , containers + , gbs-downloader + , megaparsec + , tahoe-directory + , tahoe-ssk >=0.2 && <0.3 + , text + , yaml + + hs-source-dirs: list-dircap + default-language: Haskell2010 + + test-suite gbs-downloader-test -- Import common warning flags. import: diff --git a/list-dircap/Main.hs b/list-dircap/Main.hs new file mode 100644 index 0000000000000000000000000000000000000000..60d8924ebad0169ff4e2ce503469b2b9e733f903 --- /dev/null +++ b/list-dircap/Main.hs @@ -0,0 +1,37 @@ +{-# LANGUAGE FlexibleContexts #-} + +module Main where + +import qualified Data.ByteString as B + +-- import qualified Data.ByteString.Char8 as C8 +-- import qualified Data.ByteString.Lazy as BL +import qualified Data.Text as T +import Data.Yaml (decodeEither') +import System.Environment (getArgs) +import Tahoe.Announcement (Announcements (..)) +import qualified Tahoe.Directory as TD +import Text.Megaparsec (parse) + +-- import Tahoe.Download (announcementToMutableStorageServer, download) + +main :: IO () +main = do + [announcementPath, dirReadCap] <- getArgs + -- Load server announcements + announcementsBytes <- B.readFile announcementPath + let Right (Announcements _announcements) = decodeEither' announcementsBytes + + -- Accept & parse read capability + case parse TD.pReadSDMF "<argv>" (T.pack dirReadCap) of + Left e -> print $ "Failed to parse cap: " <> show e + Right r -> print r + +-- where +-- go announcements cap = do +-- -- Download & decode the shares +-- result <- download announcements cap announcementToMutableStorageServer + +-- -- Show the result +-- putStrLn "Your result:" +-- either print (C8.putStrLn . BL.toStrict) result