Forward the --verbose flag to bupstash put.
Also pass --print-stats so that backup statistics are always
emitted by bupstash put.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Change-Id: Iac397a4a120c624dfbdeb168d7e27112cb523b72
diff --git a/src/Mulkup/Bupstash.hs b/src/Mulkup/Bupstash.hs
index 22ae70e..0d6fe91 100644
--- a/src/Mulkup/Bupstash.hs
+++ b/src/Mulkup/Bupstash.hs
@@ -7,6 +7,7 @@
module Mulkup.Bupstash (BupItem(..), Bupstash (..), bupPut, bupGc, bupList, bupRemove, BupFilter (..), runBupstash, bupItemUTCTime) where
import Mulkup.Config (MulkupConfig (..))
+import Mulkup.Flags (Flags (..))
import Mulkup.Prelude hiding (put)
import Optics
import Polysemy
@@ -56,15 +57,16 @@
-- * Implementation
--- | Runs a 'Bupstash' using the “bupstash” CLI command.
-runBupstash :: (Member (Error Text) r, Member (Log Message) r, Member (Embed IO) r, Member (Reader MulkupConfig) r) => Sem (Bupstash ': r) a -> Sem r a
+-- | Runs a 'Bupstash' using the "bupstash" CLI command.
+runBupstash :: (Member (Error Text) r, Member (Log Message) r, Member (Embed IO) r, Member (Reader MulkupConfig) r, Member (Reader Flags) r) => Sem (Bupstash ': r) a -> Sem r a
runBupstash = interpret \case
BupGc ->
procs "bupstash" ["gc"] empty
BupPut baseDir exclusions labels -> do
host <- getHost
- procs "bupstash" (["put", "--xattrs"] ++ map exclusionArg exclusions ++ map labelArg labels ++ [labelArg ("host", host)] ++ [baseDir]) empty
+ verboseArg <- getVerboseArg
+ procs "bupstash" (["put", "--print-stats", "--xattrs"] ++ verboseArg ++ map exclusionArg exclusions ++ map labelArg labels ++ [labelArg ("host", host)] ++ [baseDir]) empty
BupList bupFilter -> do
host <- getHost
@@ -87,6 +89,11 @@
getHost =
asks @MulkupConfig (^. #host)
+ getVerboseArg :: (Member (Reader Flags) r) => Sem r [Text]
+ getVerboseArg = do
+ isVerbose <- asks @Flags (^. #verbose)
+ return $ if isVerbose then ["-v"] else []
+
-- | Fixes up the buggy two-line output that Buptash produces in
-- jsonl1 output mode.
--
diff --git a/src/Mulkup/Main.hs b/src/Mulkup/Main.hs
index 829ef5d..32c63ea 100644
--- a/src/Mulkup/Main.hs
+++ b/src/Mulkup/Main.hs
@@ -39,6 +39,7 @@
& runBupstash
& runLogAction @IO messageAction
& runReader (config :: MulkupConfig)
+ & runReader flags
& errorToIOFinal @Text
& embedToFinal @IO
& runFinal @IO