From ed7f18154f323fc21a7f8cb1a017c8cc0e13c6a8 Mon Sep 17 00:00:00 2001 From: voidlizard Date: Fri, 21 Feb 2025 09:32:22 +0300 Subject: [PATCH] wip --- hbs2-cli/lib/HBS2/CLI/Run/KeyMan.hs | 23 ++++++++++++----------- hbs2-git3/bf6/hbs2-git | 7 +++++++ hbs2-git3/lib/HBS2/Git3/Run.hs | 9 +++++---- nix/bf6-hbs2-git.nix | 5 ++++- 4 files changed, 28 insertions(+), 16 deletions(-) create mode 100755 hbs2-git3/bf6/hbs2-git diff --git a/hbs2-cli/lib/HBS2/CLI/Run/KeyMan.hs b/hbs2-cli/lib/HBS2/CLI/Run/KeyMan.hs index 1f29363c..3c03abda 100644 --- a/hbs2-cli/lib/HBS2/CLI/Run/KeyMan.hs +++ b/hbs2-cli/lib/HBS2/CLI/Run/KeyMan.hs @@ -38,16 +38,17 @@ keymanEntries = do entry $ bindMatch "hbs2:keyman:config" $ \_ -> do mkForm "dict" <$> keymanGetConfig - entry $ bindMatch "hbs2:keyman:keys:add" $ \case - [ LitStrVal ke ] -> do - conf <- keymanGetConfig @C - path <- getDefaultKeyPath conf - let n = hashObject @HbSync (serialise ke) & pretty & show - let fname = n `addExtension` ".key" - let fpath = path fname - liftIO $ TIO.writeFile fpath ke - keymanUpdate - pure $ mkStr fpath + args [ arg "string" "keyring-data"] $ + entry $ bindMatch "hbs2:keyman:keys:add" $ \case + [ LitStrVal ke ] -> do + conf <- keymanGetConfig @C + path <- getDefaultKeyPath conf + let n = hashObject @HbSync (serialise ke) & pretty & show + let fname = n `addExtension` ".key" + let fpath = path fname + liftIO $ TIO.writeFile fpath ke + keymanUpdate + pure $ mkStr fpath - _ -> throwIO (BadFormException @C nil) + _ -> throwIO (BadFormException @C nil) diff --git a/hbs2-git3/bf6/hbs2-git b/hbs2-git3/bf6/hbs2-git new file mode 100755 index 00000000..0821268d --- /dev/null +++ b/hbs2-git3/bf6/hbs2-git @@ -0,0 +1,7 @@ +#! /usr/bin/env -S bf6 file + +(run:proc:attached hbs2-git3 (cdr *args)) + + + + diff --git a/hbs2-git3/lib/HBS2/Git3/Run.hs b/hbs2-git3/lib/HBS2/Git3/Run.hs index c9710249..8c8cc25b 100644 --- a/hbs2-git3/lib/HBS2/Git3/Run.hs +++ b/hbs2-git3/lib/HBS2/Git3/Run.hs @@ -133,10 +133,11 @@ compression ; prints compression level [ StringLike s ] -> display $ mkStr @C (show $ pretty $ gitNormaliseRef (fromString s)) _ -> throwIO (BadFormException @C nil) - entry $ bindMatch "test:hbs2:peer:poke" $ nil_ $ \syn -> do - peer <- getClientAPI @PeerAPI @UNIX - r <- callRpcWaitRetry @RpcPoke (TimeoutSec 0.5) 2 peer () >>= orThrowUser "hbs2-peer not found" - notice $ pretty r + brief "checks if hbs2-peer available" + $ entry $ bindMatch "hbs2:peer:poke" $ nil_ $ \syn -> do + peer <- getClientAPI @PeerAPI @UNIX + r <- callRpcWaitRetry @RpcPoke (TimeoutSec 0.5) 2 peer () >>= orThrowUser "hbs2-peer not found" + notice $ pretty r hidden do entry $ bindMatch "git:hash:blob" $ nil_ $ const $ liftIO do diff --git a/nix/bf6-hbs2-git.nix b/nix/bf6-hbs2-git.nix index 401de2ed..283f6138 100644 --- a/nix/bf6-hbs2-git.nix +++ b/nix/bf6-hbs2-git.nix @@ -27,5 +27,8 @@ stdenv.mkDerivation { in '' mkdir -p $out/bin cp ${p}/bin/${name} $out/bin - ''; + ''; + + + }