diff --git a/hbs2-cli/lib/HBS2/CLI/Run/Internal.hs b/hbs2-cli/lib/HBS2/CLI/Run/Internal.hs index 3a2b1c94..14c4a25b 100644 --- a/hbs2-cli/lib/HBS2/CLI/Run/Internal.hs +++ b/hbs2-cli/lib/HBS2/CLI/Run/Internal.hs @@ -80,6 +80,9 @@ instance IsContext c => OptionalVal c Int where LitIntVal x -> fromIntegral x _ -> d +hasKey :: IsContext c => Id -> [Syntax c] -> Maybe (Syntax c) +hasKey k ss = headMay [ e | ListVal [SymbolVal z, e] <- ss, z == k] + stringLike :: Syntax c -> Maybe String stringLike = \case LitStrVal s -> Just $ Text.unpack s diff --git a/hbs2-cli/lib/HBS2/CLI/Run/Sigil.hs b/hbs2-cli/lib/HBS2/CLI/Run/Sigil.hs index c1e8aeb7..81ca6b46 100644 --- a/hbs2-cli/lib/HBS2/CLI/Run/Sigil.hs +++ b/hbs2-cli/lib/HBS2/CLI/Run/Sigil.hs @@ -13,9 +13,23 @@ import Data.ByteString.Char8 qualified as BS8 import Data.Text qualified as Text import Lens.Micro.Platform + sigilEntries :: forall c m . (c ~ C, IsContext c, MonadUnliftIO m) => MakeDictM c m () sigilEntries = do + entry $ bindMatch "hbs2:sigil:sign-pubkey" $ \case + [ ListVal (SymbolVal sigil : (hasKey "sign-pubkey" -> Just s)) ] -> do + pure s + + _ -> throwIO $ BadFormException @C nil + + + entry $ bindMatch "hbs2:sigil:encrypt-pubkey" $ \case + [ ListVal (SymbolVal sigil : (hasKey "encrypt-pubkey" -> Just s)) ] -> do + pure s + + _ -> throwIO $ BadFormException @C nil + entry $ bindMatch "hbs2:sigil:parse" $ \case [StringLike s] -> do