diff --git a/bf6/hbs2 b/bf6/hbs2 index 32eda25c..2cab9fa5 100755 --- a/bf6/hbs2 +++ b/bf6/hbs2 @@ -42,6 +42,13 @@ ) ) + ( (list? [sym? hash] ...) + (begin + (local what (if (eq? (type ...) :list) ... '())) + (display (eval `(hbs2:hash ,@what))) + ) + ) + ( (list? [sym? has] hash) (begin (local s (hbs2:peer:storage:block:size hash)) diff --git a/hbs2-cli/lib/HBS2/CLI/Run/Internal.hs b/hbs2-cli/lib/HBS2/CLI/Run/Internal.hs index 9432b150..4527e6c8 100644 --- a/hbs2-cli/lib/HBS2/CLI/Run/Internal.hs +++ b/hbs2-cli/lib/HBS2/CLI/Run/Internal.hs @@ -32,6 +32,7 @@ import Control.Monad.Trans.Maybe import Control.Monad.Trans.Cont import Data.ByteString.Char8 qualified as BS8 import Data.ByteString.Lazy qualified as LBS +import Data.ByteString qualified as BS import Data.Text qualified as Text import Lens.Micro.Platform @@ -171,18 +172,22 @@ internalEntries = do -- TODO: re-implement-all-on-top-of-opaque - entry $ bindMatch "hbs2:hash" $ \syn -> do - i <- case syn of - [ListVal (StringLikeList xs)] -> pure xs - StringLikeList xs -> pure xs - e -> throwIO (BadFormException @c (mkList e)) + entry $ bindMatch "hbs2:hash" $ \case + [] -> liftIO do + LBS.getContents + <&> mkSym . HashRef . hashObject @HbSync - r <- forM i $ \f -> do - liftIO (LBS.readFile f) - <&> hashObject @HbSync - <&> mkSym @c . show . pretty + [ StringLike fn ] -> liftIO do + LBS.readFile fn + <&> mkSym . HashRef . hashObject @HbSync - pure $ mkList r + [isOpaqueOf @LBS.ByteString -> Just s ] -> do + pure $ mkSym $ HashRef $ hashObject @HbSync s + + [isOpaqueOf @BS.ByteString -> Just s ] -> do + pure $ mkSym $ HashRef $ hashObject @HbSync s + + e -> throwIO (BadFormException @c (mkList e)) entry $ bindMatch "blob:base58" $ \case [LitStrVal t] -> do