mirror of https://github.com/voidlizard/hbs2
anyref commands
This commit is contained in:
parent
7856129853
commit
18255c55f5
21
hbs2/Main.hs
21
hbs2/Main.hs
|
@ -364,6 +364,10 @@ runAnyRefGet s ss = do
|
||||||
print $ pretty ref
|
print $ pretty ref
|
||||||
exitSuccess
|
exitSuccess
|
||||||
|
|
||||||
|
runAnyRefSet :: forall s t . IsRefPubKey s => AnyRefKey t s -> HashRef -> SimpleStorage HbSync -> IO ()
|
||||||
|
runAnyRefSet s hr ss = do
|
||||||
|
updateRef ss s (fromHashRef hr)
|
||||||
|
|
||||||
withStore :: Data opts => opts -> ( SimpleStorage HbSync -> IO () ) -> IO ()
|
withStore :: Data opts => opts -> ( SimpleStorage HbSync -> IO () ) -> IO ()
|
||||||
withStore opts f = do
|
withStore opts f = do
|
||||||
|
|
||||||
|
@ -419,7 +423,8 @@ main = join . customExecParser (prefs showHelpOnError) $
|
||||||
<> command "show-peer-key" (info pShowPeerKey (progDesc "show peer key from credential file"))
|
<> command "show-peer-key" (info pShowPeerKey (progDesc "show peer key from credential file"))
|
||||||
<> command "groupkey-new" (info pNewGroupkey (progDesc "generates a new groupkey"))
|
<> command "groupkey-new" (info pNewGroupkey (progDesc "generates a new groupkey"))
|
||||||
<> command "reflog" (info pReflog (progDesc "reflog commands"))
|
<> command "reflog" (info pReflog (progDesc "reflog commands"))
|
||||||
<> command "bundle" (info pBundle(progDesc "bundle commands"))
|
<> command "bundle" (info pBundle (progDesc "bundle commands"))
|
||||||
|
<> command "anyref" (info pAnyRef (progDesc "anyref commands"))
|
||||||
)
|
)
|
||||||
|
|
||||||
common = do
|
common = do
|
||||||
|
@ -482,13 +487,23 @@ main = join . customExecParser (prefs showHelpOnError) $
|
||||||
pure $ withStore o (runRefLogGet @HBS2Basic reflogs)
|
pure $ withStore o (runRefLogGet @HBS2Basic reflogs)
|
||||||
|
|
||||||
|
|
||||||
pAnyRef = hsubparser ( command "get" (info pAnyRefGet (progDesc "get anyref value") ) )
|
pAnyRef = hsubparser ( command "get" (info pAnyRefGet (progDesc "get anyref value") )
|
||||||
|
<> command "set" (info pAnyRefSet (progDesc "set anyref value") )
|
||||||
|
)
|
||||||
|
|
||||||
pAnyRefGet = do
|
pAnyRefGet = do
|
||||||
o <- common
|
o <- common
|
||||||
anyref <- strArgument ( metavar "ANYREF" )
|
anyref <- strArgument ( metavar "ANYREF" )
|
||||||
pure $ withStore o (runAnyRefGet @HBS2Basic anyref)
|
pure $ withStore o (runAnyRefGet @HBS2Basic anyref)
|
||||||
|
|
||||||
|
pAnyRefSet = do
|
||||||
|
o <- common
|
||||||
|
anyref <- strArgument ( metavar "ANYREF" )
|
||||||
|
val <- strArgument ( metavar "HASHREF" )
|
||||||
|
pure $ do
|
||||||
|
hr <- pure (fromStringMay val) `orDie` "bad HASHREF"
|
||||||
|
withStore o (runAnyRefSet @HBS2Basic anyref hr)
|
||||||
|
|
||||||
pFsck = do
|
pFsck = do
|
||||||
o <- common
|
o <- common
|
||||||
pure $ withStore o $ \sto -> do
|
pure $ withStore o $ \sto -> do
|
||||||
|
@ -628,3 +643,5 @@ main = join . customExecParser (prefs showHelpOnError) $
|
||||||
|
|
||||||
printHash = void . print . pretty . fst
|
printHash = void . print . pretty . fst
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue