diff --git a/bf6/hbs23 b/bf6/hbs23 index af9c9543..6da75d1b 100755 --- a/bf6/hbs23 +++ b/bf6/hbs23 @@ -7,9 +7,26 @@ (match *args ( (list? [sym? store] ...) (begin - # (local optdef (kw -g 1 --group-key 1)) - # (local opts (cli:split optdef ...)) - (println "FUCKING STORE " ... )) + (local optdef (kw -g 1 --group-key 1)) + (local cli (cli:split optdef ...)) + (local opts (nth 0 cli)) + (local gk1 (lookup:uw --group-key opts)) + (local gk2 (lookup:uw -g opts)) + (local gk (car (filter [fn x . [not [nil? x]]] `[,gk1 ,gk2]))) + (local fname (head (nth 1 cli))) + + (local kwa `[ ,(if gk [list :gk gk] '() ) + ] + ) + + [local r + (if fname + (hbs2:tree:metadata:file kwa fname) + (hbs2:tree:metadata:stdin kwa))] + + (display r) + + ) ) diff --git a/hbs2-cli/lib/HBS2/CLI/Run/MetaData.hs b/hbs2-cli/lib/HBS2/CLI/Run/MetaData.hs index 1ea0afed..342c5d88 100644 --- a/hbs2-cli/lib/HBS2/CLI/Run/MetaData.hs +++ b/hbs2-cli/lib/HBS2/CLI/Run/MetaData.hs @@ -29,6 +29,7 @@ import Control.Monad.Trans.Maybe import Control.Monad.Trans.Cont import Data.ByteString.Lazy qualified as LBS import Data.ByteString.Lazy (ByteString) +import Data.ByteString.Char8 qualified as BS8 import Data.Either import Data.Set qualified as Set import Data.HashMap.Strict qualified as HM @@ -225,7 +226,10 @@ file-name: "qqq.txt" metadataCreateMan $ args [kw] $ entry $ bindMatch "hbs2:tree:metadata:stdin" $ \case [syn@(ListVal{})] -> do - doCreateMetadataTree mempty syn (liftIO LBS.getContents) + _reader <- hIsTerminalDevice stdin >>= \case + _ -> pure (liftIO LBS.getContents) + + doCreateMetadataTree mempty syn _reader _ -> throwIO (BadFormException @c nil)