]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
[zstdcli] Add --no-progress flag 1450/head
authorNick Terrell <terrelln@fb.com>
Fri, 14 Dec 2018 01:17:32 +0000 (17:17 -0800)
committerNick Terrell <terrelln@fb.com>
Fri, 14 Dec 2018 19:50:25 +0000 (11:50 -0800)
The `--no-progress` flag disables zstd's progress bars, but leaves
the summary.

I've added simple tests to `playTests.sh` to make sure the parsing
works.

programs/fileio.c
programs/fileio.h
programs/zstd.1.md
programs/zstdcli.c
tests/playTests.sh

index cda5295b4b8fea9ec168ccfdda12e79a9a569873..434443bfcde5c6e3f6c7b69fbd14ad7af7794c44 100644 (file)
@@ -88,10 +88,10 @@ void FIO_setNotificationLevel(unsigned level) { g_displayLevel=level; }
 static const U64 g_refreshRate = SEC_TO_MICRO / 6;
 static UTIL_time_t g_displayClock = UTIL_TIME_INITIALIZER;
 
-#define READY_FOR_UPDATE() (UTIL_clockSpanMicro(g_displayClock) > g_refreshRate)
+#define READY_FOR_UPDATE() (!g_noProgress && UTIL_clockSpanMicro(g_displayClock) > g_refreshRate)
 #define DELAY_NEXT_UPDATE() { g_displayClock = UTIL_getTime(); }
 #define DISPLAYUPDATE(l, ...) {                              \
-        if (g_displayLevel>=l) {                             \
+        if (g_displayLevel>=l && !g_noProgress) {            \
             if (READY_FOR_UPDATE() || (g_displayLevel>=4)) { \
                 DELAY_NEXT_UPDATE();                         \
                 DISPLAY(__VA_ARGS__);                        \
@@ -350,6 +350,10 @@ static U32 g_ldmHashRateLog = FIO_LDM_PARAM_NOTSET;
 void FIO_setLdmHashRateLog(unsigned ldmHashRateLog) {
     g_ldmHashRateLog = ldmHashRateLog;
 }
+static U32 g_noProgress = 0;
+void FIO_setNoProgress(unsigned noProgress) {
+    g_noProgress = noProgress;
+}
 
 
 
index 7e1b1cd761b76f39780846a44f6ffa2d1d95202a..97f27063207179775eaba934ee5a945f8fc72101 100644 (file)
@@ -66,6 +66,7 @@ void FIO_setOverlapLog(unsigned overlapLog);
 void FIO_setRemoveSrcFile(unsigned flag);
 void FIO_setSparseWrite(unsigned sparse);  /**< 0: no sparse; 1: disable on stdout; 2: always enabled */
 void FIO_setRsyncable(unsigned rsyncable);
+void FIO_setNoProgress(unsigned noProgress);
 
 
 /*-*************************************
index 34810541778344f9c793af1d6de693b82360420b..878968c1d2b5afba3b751de4c4efa685c8627616 100644 (file)
@@ -195,6 +195,8 @@ the last one takes effect.
 * `-q`, `--quiet`:
     suppress warnings, interactivity, and notifications.
     specify twice to suppress errors too.
+* `--no-progress`:
+    do not display the progress bar, but keep all other messages.
 * `-C`, `--[no-]check`:
     add integrity check computed from uncompressed data (default: enabled)
 * `--`:
index 57440e3c021be68672ecde9d998e1e7b884f3e13..e69661d5e5da5cc1ad806cb3fe7a4b53796c2daf 100644 (file)
@@ -171,6 +171,7 @@ static int usage_advanced(const char* programName)
 #endif
 #endif
     DISPLAY( " -M#    : Set a memory usage limit for decompression \n");
+    DISPLAY( "--no-progress : do not display the progress bar \n");
     DISPLAY( "--      : All arguments after \"--\" are treated as files \n");
 #ifndef ZSTD_NODICT
     DISPLAY( "\n");
@@ -610,6 +611,7 @@ int main(int argCount, const char* argv[])
                     if (!strcmp(argument, "--format=lz4")) { suffix = LZ4_EXTENSION; FIO_setCompressionType(FIO_lz4Compression);  continue; }
 #endif
                     if (!strcmp(argument, "--rsyncable")) { rsyncable = 1; continue; }
+                    if (!strcmp(argument, "--no-progress")) { FIO_setNoProgress(1); continue; }
 
                     /* long commands with arguments */
 #ifndef ZSTD_NODICT
index 9b3915a7692651327eba82d5494262c1548532cb..ab9886d4b237de9285313d7df7bbd792a78bd982 100755 (executable)
@@ -179,6 +179,9 @@ $ECHO foo > tmpro
 chmod 400 tmpro.zst
 $ZSTD -q tmpro && die "should have refused to overwrite read-only file"
 $ZSTD -q -f tmpro
+$ECHO "test: --no-progress flag"
+$ZSTD tmpro -c --no-progress | $ZSTD -d -o "$INTOVOID" --no-progress
+$ZSTD tmpro -cv --no-progress | $ZSTD -dv -o "$INTOVOID" --no-progress
 rm -f tmpro tmpro.zst