Skip to content

Commit e220c88

Browse files
committed
mismi-cli: Add a --recursive option for download
1 parent 38d599f commit e220c88

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

mismi-cli/main/s3.hs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ data UnitPrefix =
6969

7070
data Command =
7171
Upload FilePath Address WriteMode
72-
| Download Address FilePath
72+
| Download Recursive Address FilePath
7373
| Copy Address Address WriteMode
7474
| Concat [Address] Address WriteMode Int
7575
| Move Address Address
@@ -128,8 +128,10 @@ run c = do
128128
orDie O.renderError . O.runAWS e' $ case c of
129129
Upload s d m ->
130130
uploadWithModeOrFail m s d
131-
Download s d ->
131+
Download NotRecursive s d ->
132132
renderExit renderDownloadError . download s . optAppendFileName d $ key s
133+
Download Recursive s d ->
134+
renderExit renderDownloadError $ downloadRecursive s d
133135
Copy s d m ->
134136
renderExit renderCopyError $ copyWithMode m s d
135137
Concat ss d m f ->
@@ -165,6 +167,7 @@ sizeRecursive root d p =
165167
bytes <- sizeRecursively' root $$ DC.map sizedBytes =$= DC.fold (+) 0
166168
liftIO . T.putStrLn $ renderSizedAddress p (Sized bytes root)
167169

170+
168171
renderSizedAddress :: UnitPrefix -> Sized Address -> Text
169172
renderSizedAddress p (Sized bytes address) =
170173
let
@@ -299,7 +302,7 @@ commandP' f = XOA.subparser $
299302
(Upload <$> filepath' <*> address' <*> writeMode' f)
300303
<> command' "download"
301304
"Download a file from s3."
302-
(Download <$> address' <*> filepath')
305+
(Download <$> recursive' <*> address' <*> filepath')
303306
<> command' "copy"
304307
"Copy a file from an S3 address to another S3 address."
305308
(Copy <$> address' <*> address' <*> writeMode' f)

0 commit comments

Comments
 (0)