added man entry for repo:init

This commit is contained in:
voidlizard 2025-02-19 13:41:20 +03:00
parent 71679e5b65
commit 0786150ef4
3 changed files with 48 additions and 8 deletions

View File

@ -10,7 +10,6 @@ import HBS2.Git3.Export
import HBS2.System.Dir import HBS2.System.Dir
import HBS2.CLI.Run.MetaData
import HBS2.Net.Auth.Credentials import HBS2.Net.Auth.Credentials
import HBS2.Net.Auth.GroupKeySymm import HBS2.Net.Auth.GroupKeySymm
@ -19,11 +18,8 @@ import HBS2.KeyMan.Keys.Direct
import Data.Config.Suckless.Script import Data.Config.Suckless.Script
import Data.Config.Suckless.Almost.RPC import Data.Config.Suckless.Almost.RPC
import Data.ByteString.Lazy.Char8 qualified as LBS8
import Data.Word import Data.Word
import Data.Maybe
import Data.Text qualified as Text import Data.Text qualified as Text
import Data.HashMap.Strict qualified as HM
import Lens.Micro.Platform import Lens.Micro.Platform
import System.Random hiding (next) import System.Random hiding (next)

View File

@ -560,13 +560,57 @@ compression ; prints compression level
liftIO $ for_ keys $ \k -> do liftIO $ for_ keys $ \k -> do
liftIO $ print $ pretty k liftIO $ print $ pretty k
let initExamples = [qc|
; just init a new repository
hbs2-git init --new
; init encrypted repository
; create new group key:
; your real keys will be different
; all hashes/keys appear in exampels/logs a PUBLIC information,
; so no secrets disclosures.
hbs2-cli hbs2:groupkey:store [hbs2:groupkey:create 67CRxnoQWasQsY9iidjJDYXSTKEZkpSVgDQYweWuhfd3]
39baH7SqqsAGgCSr3k9RJgY4nTwiMRXrgZUmKPFndzn8
hbs2-git init --new --encrypted 39baH7SqqsAGgCSr3k9RJgY4nTwiMRXrgZUmKPFndzn8
added git remote laundry-worry hbs23://7F1D7QGVVwJFJ649dsSHgrDUuqHYti3nkFx<censored>
updateRepoKey 7F1D7QGVVwJFJ649dsSHgrDUuqHYti3nkFx<censored>
git remote
laundry-worry
^^^^^^^^^^^^^
This is the git remote for the new repo. Rename it if you want.
hbs2-git3 repo:remotes
7F1D7QGVVwJFJ649dsSHgrDUuqHYti3nkFx<censored> laundry-worry
|]
let initMan = brief "initializes a new repository"
. args [ arg "new repository flag" "--new"
, arg "group key hash for encrypted repository" "<--encrypted group-key>"
]
. examples initExamples
initMan $
entry $ bindMatch "repo:init" $ nil_ $ \syn -> lift $ connectedDo do entry $ bindMatch "repo:init" $ nil_ $ \syn -> lift $ connectedDo do
Repo.initRepo syn Repo.initRepo syn
initMan $ entry $
bindAlias "init" "repo:init"
entry $ bindMatch "repo:relay-only" $ nil_ $ \case entry $ bindMatch "repo:relay-only" $ nil_ $ \case
[ SignPubKeyLike repo ] -> lift $ connectedDo do [ SignPubKeyLike repo ] -> lift $ connectedDo do
setGitRepoKey repo setGitRepoKey repo
waitRepo (Just 3) =<< getGitRepoKeyThrow waitRepo (Just 10) =<< getGitRepoKeyThrow
_ -> throwIO (BadFormException @C nil) _ -> throwIO (BadFormException @C nil)

View File

@ -262,7 +262,7 @@ waitRepo timeout repoKey = do
notice "wait for peer" notice "wait for peer"
lift (callRpcWaitMay @RpcPollAdd (TimeoutSec 1) peerAPI (repoKey, "lwwref", 31)) lift (callRpcWaitMay @RpcPollAdd (TimeoutSec 2) peerAPI (repoKey, "lwwref", 31))
>>= maybe (wait 1 forPeer ()) (const none) >>= maybe (wait 1 forPeer ()) (const none)
pFetch <- ContT $ withAsync $ forever do pFetch <- ContT $ withAsync $ forever do