diff --git a/docs/NEWS.md b/docs/NEWS.md index fc75c4f..5cb671a 100644 --- a/docs/NEWS.md +++ b/docs/NEWS.md @@ -2,6 +2,7 @@ * feature: new "`--stats`" option to show transfer stats at the end, like "`ping`" ([#49](https://codeberg.org/a-j-wood/pv/issues/49)) * feature: "`--rate`" can now be used with "`--numeric`" ([#17](https://codeberg.org/a-j-wood/pv/issues/17)) + * feature: "`--gauge`" with "`--progress`" to show rate gauge when size is unknown ([#46](https://codeberg.org/a-j-wood/pv/issues/46)) * i18n: complete set of German translations supplied by Hartmut Goebel ([#98](https://codeberg.org/a-j-wood/pv/pulls/98)) * fix: resume stopped pipelines when running in the background (part of [#56](https://codeberg.org/a-j-wood/pv/issues/56)) * fix: prefix completion time ("`--fineta`") with *FIN* rather than *ETA* ([#43](https://codeberg.org/a-j-wood/pv/issues/43)) diff --git a/docs/pv.1 b/docs/pv.1 index a167f65..095d971 100644 --- a/docs/pv.1 +++ b/docs/pv.1 @@ -118,7 +118,10 @@ unreadable, and no size was explicitly given (with the .B \-s modifier), the progress bar cannot indicate how close to completion the transfer is, so it will just move left and right to indicate that data is -moving. +moving - or, with +.BR \-\-gauge , +the bar will indicate the current rate as a percentage of the maximum rate +seen so far. .TP .B \-t, \-\-timer Turn the timer on. This will display the total elapsed time that @@ -289,6 +292,11 @@ has no effect if used with to watch all file descriptors of a process, but will work with .BR "-d PID:FD" . .TP +.B \-g, \-\-gauge +If the progress bar is shown but the size is not known, then instead of +moving the bar left and right to show progress, show the current transfer +rate as a percentage of the maximum rate seen so far. +.TP .B \-l, \-\-line\-mode Instead of counting bytes, count lines (newline characters). The progress bar will only move when a new line is found, and the value passed to the @@ -635,6 +643,14 @@ average rate, and current rate. Show a progress bar, elapsed time, estimated completion time, line counter, and average rate, counting lines instead of bytes. .TP +.B pv -btrpg +Show the amount transferred, elapsed time, current rate, and a gauge showing +the current rate as a percentage of the maximum rate seen - useful in a +pipeline where the total size is unknown. (If the size +.I is +known, these options will show the percentage completion instead of the rate +gauge). +.TP .B pv -t Show only the elapsed time - useful as a simple timer, e.g. .BR "sleep 10m | pv -t" . diff --git a/docs/pv.1.md b/docs/pv.1.md index a2df21a..49ab081 100644 --- a/docs/pv.1.md +++ b/docs/pv.1.md @@ -80,7 +80,8 @@ display types that are explicitly switched on will be shown. unreadable, and no size was explicitly given (with the **-s** modifier), the progress bar cannot indicate how close to completion the transfer is, so it will just move left and right to indicate - that data is moving. + that data is moving - or, with **\--gauge**, the bar will indicate + the current rate as a percentage of the maximum rate seen so far. **-t, \--timer** @@ -207,6 +208,12 @@ display types that are explicitly switched on will be shown. watch all file descriptors of a process, but will work with **-d PID:FD**. +**-g, \--gauge** + +: If the progress bar is shown but the size is not known, then instead + of moving the bar left and right to show progress, show the current + transfer rate as a percentage of the maximum rate seen so far. + **-l, \--line-mode** : Instead of counting bytes, count lines (newline characters). The @@ -474,6 +481,14 @@ Some suggested common switch combinations: : Show a progress bar, elapsed time, estimated completion time, line counter, and average rate, counting lines instead of bytes. +**pv -btrpg** + +: Show the amount transferred, elapsed time, current rate, and a gauge + showing the current rate as a percentage of the maximum rate seen - + useful in a pipeline where the total size is unknown. (If the size + *is* known, these options will show the percentage completion + instead of the rate gauge). + **pv -t** : Show only the elapsed time - useful as a simple timer, e.g. **sleep diff --git a/po/de.po b/po/de.po index 3a76a1b..3aa0f06 100644 --- a/po/de.po +++ b/po/de.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Report-Msgid-Bugs-To: pv@ivarch.com\n" -"POT-Creation-Date: 2024-10-04 19:39+0100\n" +"POT-Creation-Date: 2024-10-04 22:08+0100\n" "PO-Revision-Date: 2024-09-29 11:07+0000\n" "Last-Translator: a-j-wood \n" "Language-Team: German \n" @@ -50,7 +50,7 @@ msgstr "zeige die Datentransferrate an" msgid "show data transfer average rate counter" msgstr "zeige die durchschnittliche Übertragungsrate" -#: src/main/help.c:301 src/main/help.c:335 src/main/help.c:347 +#: src/main/help.c:301 src/main/help.c:335 src/main/help.c:350 msgid "SEC" msgstr "SEK" @@ -121,147 +121,151 @@ msgid "set estimated data size to SIZE bytes" msgstr "setze erwartete Datenlänge auf SIZE Byte" #: src/main/help.c:342 +msgid "if size unknown, show rate vs max rate" +msgstr "" + +#: src/main/help.c:345 msgid "count lines instead of bytes" msgstr "zähle Zeilen anstelle von Bytes" -#: src/main/help.c:345 +#: src/main/help.c:348 msgid "lines are null-terminated" msgstr "Zeilen sind nullterminiert" -#: src/main/help.c:348 +#: src/main/help.c:351 msgid "update every SEC seconds" msgstr "aktualisiere Ausgabe nach SEK Sekunden Intervall" -#: src/main/help.c:350 +#: src/main/help.c:353 msgid "WIDTH" msgstr "BREITE" -#: src/main/help.c:351 +#: src/main/help.c:354 msgid "assume terminal is WIDTH characters wide" msgstr "setze Terminal-Breite auf BREITE Zeichen" -#: src/main/help.c:353 +#: src/main/help.c:356 msgid "HEIGHT" msgstr "HÖHE" -#: src/main/help.c:354 +#: src/main/help.c:357 msgid "assume terminal is HEIGHT rows high" msgstr "setze Terminal-Höhe auf HÖHE Zeichen" -#: src/main/help.c:356 +#: src/main/help.c:359 msgid "NAME" msgstr "NAME" -#: src/main/help.c:357 +#: src/main/help.c:360 msgid "prefix visual information with NAME" msgstr "setze den NAMEn für visuelle Darstellung" -#: src/main/help.c:360 +#: src/main/help.c:363 msgid "output even if standard error is not a terminal" msgstr "" "Ausgabe auch dann erzwingen, wenn der Fehlerausgabe-Kanal kein Terminal ist" -#: src/main/help.c:363 +#: src/main/help.c:366 msgid "use cursor positioning escape sequences" msgstr "benutze Escape-Sequenzen zur Cursor-Positionierung" -#: src/main/help.c:366 src/main/help.c:402 src/main/help.c:417 +#: src/main/help.c:369 src/main/help.c:405 src/main/help.c:420 msgid "FILE" msgstr "DATEI" -#: src/main/help.c:367 +#: src/main/help.c:370 msgid "write output to FILE instead of stdout" msgstr "schreibe die Ausgabe in DATEI statt in die Standardausgabe" -#: src/main/help.c:369 +#: src/main/help.c:372 msgid "RATE" msgstr "RATE" -#: src/main/help.c:370 +#: src/main/help.c:373 msgid "limit transfer to RATE bytes per second" msgstr "beschränke die Transferrate auf RATE Byte pro Sekunde" -#: src/main/help.c:372 src/main/help.c:381 +#: src/main/help.c:375 src/main/help.c:384 msgid "BYTES" msgstr "BYTES" -#: src/main/help.c:373 +#: src/main/help.c:376 msgid "use a buffer size of BYTES" msgstr "benutze einen Puffer in der Größe von BYTES" -#: src/main/help.c:376 +#: src/main/help.c:379 msgid "never use splice(), always use read/write" msgstr "anstelle von splice() immer read/write benutzen" -#: src/main/help.c:379 +#: src/main/help.c:382 msgid "skip read errors in input" msgstr "Lesefehler in der Eingabe nicht beachten" -#: src/main/help.c:382 +#: src/main/help.c:385 msgid "skip errors in BYTES blocks at a time" msgstr "bei Fehlern BYTES am Stück überspringen" -#: src/main/help.c:385 +#: src/main/help.c:388 msgid "stop after --size bytes have been transferred" msgstr "anhalten, nachdem --size Bytes übertragen wurden" -#: src/main/help.c:388 +#: src/main/help.c:391 msgid "flush cache to disk after every write" msgstr "schreibe den Cache nach jedem Schreibvorgang auf die Festplatte" -#: src/main/help.c:391 +#: src/main/help.c:394 msgid "use direct I/O to bypass cache" msgstr "verwende direkte E/A, um den Cache zu umgehen" -#: src/main/help.c:394 +#: src/main/help.c:397 msgid "discard input instead of writing to output" msgstr "verwirf die Eingabe anstatt in die Ausgabe zu schreiben" -#: src/main/help.c:397 +#: src/main/help.c:400 msgid "PID" msgstr "PID" -#: src/main/help.c:398 +#: src/main/help.c:401 msgid "update settings of process PID" msgstr "Einstellungen der Prozess-PID updaten" -#: src/main/help.c:403 +#: src/main/help.c:406 msgid "save process ID in FILE" msgstr "Prozess-ID in DATEI speichern" -#: src/main/help.c:406 +#: src/main/help.c:409 msgid "PID[:FD]" msgstr "PID[:FD]" -#: src/main/help.c:407 +#: src/main/help.c:410 msgid "watch file FD opened by process PID" msgstr "die vom Prozess PID geöffnete Datei FD beobachten" -#: src/main/help.c:411 +#: src/main/help.c:414 msgid "show this help and exit" msgstr "zeige diese Hilfe und beende" -#: src/main/help.c:414 +#: src/main/help.c:417 msgid "show version information and exit" msgstr "zeige Versionsinformationen und beende" -#: src/main/help.c:418 +#: src/main/help.c:421 msgid "write debug logs to FILE" msgstr "schreibe Debug-Protokolle in DATEI" -#: src/main/help.c:443 +#: src/main/help.c:446 #, c-format msgid "Usage: %s [OPTION] [FILE]..." msgstr "Aufruf: %s [OPTION] [DATEI]..." -#: src/main/help.c:454 +#: src/main/help.c:457 msgid "" "Concatenate FILE(s), or standard input, to standard output, with monitoring." msgstr "" "Verbindet DATEI(en) oder den Standard-Eingabe-Kanal mit dem Standard-Ausgabe-" "Kanal und misst den Datenstrom." -#: src/main/help.c:591 +#: src/main/help.c:594 #, c-format msgid "Please report any bugs to: %s" msgstr "Bitte senden Sie Fehlerberichte an %s" @@ -294,41 +298,41 @@ msgstr "konnte Blockgerät nicht öffnen" msgid "failed to determine size of block device" msgstr "konnte Größe des Blockgeräts nicht ermitteln" -#: src/main/options.c:335 +#: src/main/options.c:336 msgid "option structure allocation failed" msgstr "Speicherzuweisung für `option' fehlgeschlagen" -#: src/main/options.c:354 +#: src/main/options.c:355 msgid "option structure argv allocation failed" msgstr "Speicherzuweisung für `argv' der Option fehlgeschlagen" -#: src/main/options.c:416 +#: src/main/options.c:417 msgid "integer argument expected" msgstr "Ganzzahliges Argument erwartet" -#: src/main/options.c:427 +#: src/main/options.c:428 msgid "numeric argument expected" msgstr "numerisches Argument erwartet" -#: src/main/options.c:438 +#: src/main/options.c:439 msgid "process ID or pid:fd pair expected" msgstr "Prozess-ID oder PID:FD-Paar erwartet" -#: src/main/options.c:445 +#: src/main/options.c:446 msgid "invalid process ID" msgstr "ungültige Prozess-ID" -#: src/main/options.c:651 +#: src/main/options.c:655 #, c-format msgid "Try `%s --help' for more information." msgstr "`%s --help' zeigt weitere Informationen an." -#: src/main/options.c:653 +#: src/main/options.c:657 #, c-format msgid "Try `%s -h' for more information." msgstr "`%s -h' zeigt weitere Informationen an." -#: src/main/options.c:684 +#: src/main/options.c:688 msgid "" "cannot use line mode or transfer modifier options when watching file " "descriptors" @@ -336,24 +340,24 @@ msgstr "" "Beim Beobachten von Dateideskriptoren können keine Optionen für den " "Zeilenmodus oder den Übertragungsmodifikator verwendet werden" -#: src/main/options.c:693 +#: src/main/options.c:697 msgid "cannot use cursor positioning when watching file descriptors" msgstr "" "Beim Beobachten von Dateideskriptoren kann Cursor-Positionierung nicht " "verwendet werden" -#: src/main/options.c:702 +#: src/main/options.c:706 msgid "cannot use remote control when watching file descriptors" msgstr "" "Beim Beobachten von Dateideskriptoren kann die Fernbedienung nicht verwenden " "werden" -#: src/main/options.c:711 +#: src/main/options.c:715 msgid "cannot transfer files when watching file descriptors" msgstr "" "Beim Beobachten von Dateideskriptoren können Dateien nicht übertragen werden" -#: src/main/options.c:726 +#: src/main/options.c:730 msgid "not available on systems without /proc/self/fdinfo" msgstr "Nicht verfügbar auf Systemen ohne /proc/self/fdinfo" @@ -405,35 +409,37 @@ msgstr "yzafpnµm kMGTPEZY" msgid "yzafpnum KMGTPEZY" msgstr "yzafpnµm KMGTPEZY" -#: src/pv/display.c:653 src/pv/transfer.c:970 +#: src/pv/display.c:661 src/pv/transfer.c:970 msgid "buffer allocation failed" msgstr "Speicherzuweisung für den Puffer fehlgeschlagen" -#: src/pv/display.c:789 +#: src/pv/display.c:790 msgid "b" msgstr "b" -#: src/pv/display.c:792 src/pv/transfer.c:602 +#: src/pv/display.c:793 src/pv/transfer.c:602 msgid "B" msgstr "B" -#: src/pv/display.c:836 src/pv/display.c:851 src/pv/loop.c:418 +#: src/pv/display.c:837 src/pv/display.c:852 src/pv/display.c:1071 +#: src/pv/loop.c:418 msgid "b/s" msgstr "b/s" -#: src/pv/display.c:840 src/pv/display.c:855 +#: src/pv/display.c:841 src/pv/display.c:856 src/pv/display.c:1075 msgid "/s" msgstr "/s" -#: src/pv/display.c:840 src/pv/display.c:855 src/pv/loop.c:418 +#: src/pv/display.c:841 src/pv/display.c:856 src/pv/display.c:1075 +#: src/pv/loop.c:418 msgid "B/s" msgstr "B/s" -#: src/pv/display.c:883 src/pv/display.c:887 +#: src/pv/display.c:884 src/pv/display.c:888 msgid "ETA" msgstr "ETA" -#: src/pv/display.c:953 +#: src/pv/display.c:954 msgid "FIN" msgstr "" @@ -485,7 +491,7 @@ msgstr "pid" msgid "history structure allocation failed" msgstr "Speicherzuweisung für `history' fehlgeschlagen" -#: src/pv/state.c:465 src/pv/state.c:476 +#: src/pv/state.c:470 src/pv/state.c:481 msgid "file list allocation failed" msgstr "Speicherzuweisung für die Dateiliste fehlgeschlagen" diff --git a/po/fr.po b/po/fr.po index 4dfdc52..128cec1 100644 --- a/po/fr.po +++ b/po/fr.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Report-Msgid-Bugs-To: pv@ivarch.com\n" -"POT-Creation-Date: 2024-10-04 19:39+0100\n" +"POT-Creation-Date: 2024-10-04 22:08+0100\n" "Language: fr\n" "Content-Type: text/plain; charset=UTF-8\n" "Date: 1999-06-01 15:18:29+0100\n" @@ -44,7 +44,7 @@ msgstr "afficher le taux de tranfert des données" msgid "show data transfer average rate counter" msgstr "afficher le compteur de taux moyen de transfert de données" -#: src/main/help.c:301 src/main/help.c:335 src/main/help.c:347 +#: src/main/help.c:301 src/main/help.c:335 src/main/help.c:350 msgid "SEC" msgstr "SEC" @@ -114,147 +114,151 @@ msgid "set estimated data size to SIZE bytes" msgstr "ajuster la taille estimée des données à TAILLE octets" #: src/main/help.c:342 +msgid "if size unknown, show rate vs max rate" +msgstr "" + +#: src/main/help.c:345 msgid "count lines instead of bytes" msgstr "compter les lignes au lieu des octets" -#: src/main/help.c:345 +#: src/main/help.c:348 msgid "lines are null-terminated" msgstr "les lignes sont terminées par un caractère nul" -#: src/main/help.c:348 +#: src/main/help.c:351 msgid "update every SEC seconds" msgstr "mettre à jour toutes les SEC secondes" -#: src/main/help.c:350 +#: src/main/help.c:353 msgid "WIDTH" msgstr "LARGEUR" -#: src/main/help.c:351 +#: src/main/help.c:354 msgid "assume terminal is WIDTH characters wide" msgstr "présumer la largeur du terminal à LARGEUR caractères" -#: src/main/help.c:353 +#: src/main/help.c:356 msgid "HEIGHT" msgstr "HAUTEUR" -#: src/main/help.c:354 +#: src/main/help.c:357 msgid "assume terminal is HEIGHT rows high" msgstr "présumer la hauteur du terminal à HAUTEUR lignes" -#: src/main/help.c:356 +#: src/main/help.c:359 msgid "NAME" msgstr "NOM" -#: src/main/help.c:357 +#: src/main/help.c:360 msgid "prefix visual information with NAME" msgstr "préfixer les informations visuelles avec NOM" -#: src/main/help.c:360 +#: src/main/help.c:363 msgid "output even if standard error is not a terminal" msgstr "" "imprimer vers la sortie d'erreur standard même si ce n'est pas un terminal" -#: src/main/help.c:363 +#: src/main/help.c:366 msgid "use cursor positioning escape sequences" msgstr "utiliser les séquences d'échappements de positionnement de curseur" -#: src/main/help.c:366 src/main/help.c:402 src/main/help.c:417 +#: src/main/help.c:369 src/main/help.c:405 src/main/help.c:420 msgid "FILE" msgstr "FICHIER" -#: src/main/help.c:367 +#: src/main/help.c:370 msgid "write output to FILE instead of stdout" msgstr "" -#: src/main/help.c:369 +#: src/main/help.c:372 msgid "RATE" msgstr "TAUX" -#: src/main/help.c:370 +#: src/main/help.c:373 msgid "limit transfer to RATE bytes per second" msgstr "limite le taux de transfert à TAUX octets par seconde" -#: src/main/help.c:372 src/main/help.c:381 +#: src/main/help.c:375 src/main/help.c:384 msgid "BYTES" msgstr "OCTETS" -#: src/main/help.c:373 +#: src/main/help.c:376 msgid "use a buffer size of BYTES" msgstr "Utiliser une mémoire tampon de OCTETS octets" -#: src/main/help.c:376 +#: src/main/help.c:379 msgid "never use splice(), always use read/write" msgstr "ne jamais utiliser splice(), toujours utiliser read/write" -#: src/main/help.c:379 +#: src/main/help.c:382 msgid "skip read errors in input" msgstr "ignorer les erreurs de lecture dans l'entrée" -#: src/main/help.c:382 +#: src/main/help.c:385 msgid "skip errors in BYTES blocks at a time" msgstr "ignorer les erreurs dans OCTETS blocs à la fois" -#: src/main/help.c:385 +#: src/main/help.c:388 msgid "stop after --size bytes have been transferred" msgstr "arrêter après le transfert de --size octets" -#: src/main/help.c:388 +#: src/main/help.c:391 msgid "flush cache to disk after every write" msgstr "vider le cache sur le disque après chaque écriture" -#: src/main/help.c:391 +#: src/main/help.c:394 msgid "use direct I/O to bypass cache" msgstr "utiliser les E/S directes pour contourner le cache" -#: src/main/help.c:394 +#: src/main/help.c:397 msgid "discard input instead of writing to output" msgstr "rejeter l'entrée au lieu de l'écrire vers la sortie" -#: src/main/help.c:397 +#: src/main/help.c:400 msgid "PID" msgstr "PID" -#: src/main/help.c:398 +#: src/main/help.c:401 msgid "update settings of process PID" msgstr "mettre à jour la configuration du processus PID" -#: src/main/help.c:403 +#: src/main/help.c:406 msgid "save process ID in FILE" msgstr "enregistrer l'ID de processus dans FICHIER" -#: src/main/help.c:406 +#: src/main/help.c:409 msgid "PID[:FD]" msgstr "PID[:FD]" -#: src/main/help.c:407 +#: src/main/help.c:410 msgid "watch file FD opened by process PID" msgstr "surveiller le fichier FD ouvert par le processus PID" -#: src/main/help.c:411 +#: src/main/help.c:414 msgid "show this help and exit" msgstr "afficher cette aide puis quitter" -#: src/main/help.c:414 +#: src/main/help.c:417 msgid "show version information and exit" msgstr "afficher la version puis quitter" -#: src/main/help.c:418 +#: src/main/help.c:421 msgid "write debug logs to FILE" msgstr "écrire les journaux de déboggage vers FICHIER" -#: src/main/help.c:443 +#: src/main/help.c:446 #, c-format msgid "Usage: %s [OPTION] [FILE]..." msgstr "Utilisation : %s [OPTIONS] [FICHIER]..." -#: src/main/help.c:454 +#: src/main/help.c:457 msgid "" "Concatenate FILE(s), or standard input, to standard output, with monitoring." msgstr "" "Concaténer FICHIER(s), ou l'entrée standard, sur la sortie standard avec " "monitorage." -#: src/main/help.c:591 +#: src/main/help.c:594 #, c-format msgid "Please report any bugs to: %s" msgstr "SVP rapporter tous bogues à %s" @@ -287,41 +291,41 @@ msgstr "" msgid "failed to determine size of block device" msgstr "" -#: src/main/options.c:335 +#: src/main/options.c:336 msgid "option structure allocation failed" msgstr "l'allocation pour la structure d'une option a échoué" -#: src/main/options.c:354 +#: src/main/options.c:355 msgid "option structure argv allocation failed" msgstr "l'allocation pour la structure de l'option argv a échoué" -#: src/main/options.c:416 +#: src/main/options.c:417 msgid "integer argument expected" msgstr "Valeur entière attendue" -#: src/main/options.c:427 +#: src/main/options.c:428 msgid "numeric argument expected" msgstr "Valeur numérique attendue" -#: src/main/options.c:438 +#: src/main/options.c:439 msgid "process ID or pid:fd pair expected" msgstr "ID de processus ou paire pid:fd attendue" -#: src/main/options.c:445 +#: src/main/options.c:446 msgid "invalid process ID" msgstr "ID de processus non valide" -#: src/main/options.c:651 +#: src/main/options.c:655 #, c-format msgid "Try `%s --help' for more information." msgstr "Essayez `%s --help' pour plus d'informations." -#: src/main/options.c:653 +#: src/main/options.c:657 #, c-format msgid "Try `%s -h' for more information." msgstr "Essayez `%s -h' pour plus d'informations." -#: src/main/options.c:684 +#: src/main/options.c:688 msgid "" "cannot use line mode or transfer modifier options when watching file " "descriptors" @@ -329,25 +333,25 @@ msgstr "" "impossible d'utiliser le mode ligne ou les options de modificateur de " "transfert lors de la visualisation des descripteurs de fichiers" -#: src/main/options.c:693 +#: src/main/options.c:697 msgid "cannot use cursor positioning when watching file descriptors" msgstr "" "impossible d'utiliser le positionnement du curseur lors de la visualisation " "des descripteurs de fichier" -#: src/main/options.c:702 +#: src/main/options.c:706 msgid "cannot use remote control when watching file descriptors" msgstr "" "impossible d'utiliser la télécommande lors de la visualisation des " "descripteurs de fichiers" -#: src/main/options.c:711 +#: src/main/options.c:715 msgid "cannot transfer files when watching file descriptors" msgstr "" "impossible de transférer des fichiers lorsque vous regardez des descripteurs " "de fichiers" -#: src/main/options.c:726 +#: src/main/options.c:730 msgid "not available on systems without /proc/self/fdinfo" msgstr "non disponible sur les systèmes sans /proc/self/fdinfo" @@ -401,35 +405,37 @@ msgstr "" msgid "yzafpnum KMGTPEZY" msgstr "" -#: src/pv/display.c:653 src/pv/transfer.c:970 +#: src/pv/display.c:661 src/pv/transfer.c:970 msgid "buffer allocation failed" msgstr "échec de l'allocation de mémoire tampon" -#: src/pv/display.c:789 +#: src/pv/display.c:790 msgid "b" msgstr "" -#: src/pv/display.c:792 src/pv/transfer.c:602 +#: src/pv/display.c:793 src/pv/transfer.c:602 msgid "B" msgstr "O" -#: src/pv/display.c:836 src/pv/display.c:851 src/pv/loop.c:418 +#: src/pv/display.c:837 src/pv/display.c:852 src/pv/display.c:1071 +#: src/pv/loop.c:418 msgid "b/s" msgstr "" -#: src/pv/display.c:840 src/pv/display.c:855 +#: src/pv/display.c:841 src/pv/display.c:856 src/pv/display.c:1075 msgid "/s" msgstr "/s" -#: src/pv/display.c:840 src/pv/display.c:855 src/pv/loop.c:418 +#: src/pv/display.c:841 src/pv/display.c:856 src/pv/display.c:1075 +#: src/pv/loop.c:418 msgid "B/s" msgstr "O/s" -#: src/pv/display.c:883 src/pv/display.c:887 +#: src/pv/display.c:884 src/pv/display.c:888 msgid "ETA" msgstr "ETA" -#: src/pv/display.c:953 +#: src/pv/display.c:954 msgid "FIN" msgstr "" @@ -481,7 +487,7 @@ msgstr "" msgid "history structure allocation failed" msgstr "l'allocation de la structure de l'historique a échoué" -#: src/pv/state.c:465 src/pv/state.c:476 +#: src/pv/state.c:470 src/pv/state.c:481 msgid "file list allocation failed" msgstr "échec de l'allocation de la liste de fichiers" diff --git a/po/pl.po b/po/pl.po index fd47dd0..ffddd4d 100644 --- a/po/pl.po +++ b/po/pl.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: pv@ivarch.com\n" -"POT-Creation-Date: 2024-10-04 19:39+0100\n" +"POT-Creation-Date: 2024-10-04 22:08+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -39,7 +39,7 @@ msgstr "pokaż licznik prędkości przesyłania" msgid "show data transfer average rate counter" msgstr "" -#: src/main/help.c:301 src/main/help.c:335 src/main/help.c:347 +#: src/main/help.c:301 src/main/help.c:335 src/main/help.c:350 msgid "SEC" msgstr "WARTOŚĆ" @@ -108,146 +108,150 @@ msgid "set estimated data size to SIZE bytes" msgstr "ustaw oczekiwany rozmiar danych na WARTOŚĆ bajtów" #: src/main/help.c:342 -msgid "count lines instead of bytes" +msgid "if size unknown, show rate vs max rate" msgstr "" #: src/main/help.c:345 -msgid "lines are null-terminated" +msgid "count lines instead of bytes" msgstr "" #: src/main/help.c:348 +msgid "lines are null-terminated" +msgstr "" + +#: src/main/help.c:351 msgid "update every SEC seconds" msgstr "aktualizuj co każde WARTOŚĆ sekund" -#: src/main/help.c:350 +#: src/main/help.c:353 msgid "WIDTH" msgstr "WARTOŚĆ" -#: src/main/help.c:351 +#: src/main/help.c:354 msgid "assume terminal is WIDTH characters wide" msgstr "przyjmij, że terminal ma szerokość WARTOŚĆ znaków" -#: src/main/help.c:353 +#: src/main/help.c:356 msgid "HEIGHT" msgstr "" -#: src/main/help.c:354 +#: src/main/help.c:357 msgid "assume terminal is HEIGHT rows high" msgstr "przyjmij, że terminal ma szerokość WARTOŚĆ znaków" -#: src/main/help.c:356 +#: src/main/help.c:359 msgid "NAME" msgstr "NAZWA" -#: src/main/help.c:357 +#: src/main/help.c:360 msgid "prefix visual information with NAME" msgstr "poprzedź informacje prefiksem NAZWA" -#: src/main/help.c:360 +#: src/main/help.c:363 msgid "output even if standard error is not a terminal" msgstr "pokaż wyjście nawet gdy błędy nie są typu terminal" -#: src/main/help.c:363 +#: src/main/help.c:366 msgid "use cursor positioning escape sequences" msgstr "używaj sekwencji escape do pozycjonowania" -#: src/main/help.c:366 src/main/help.c:402 src/main/help.c:417 +#: src/main/help.c:369 src/main/help.c:405 src/main/help.c:420 msgid "FILE" msgstr "" -#: src/main/help.c:367 +#: src/main/help.c:370 msgid "write output to FILE instead of stdout" msgstr "" -#: src/main/help.c:369 +#: src/main/help.c:372 msgid "RATE" msgstr "" -#: src/main/help.c:370 +#: src/main/help.c:373 msgid "limit transfer to RATE bytes per second" msgstr "ogranicz przesyłane dane do RATE bajtów na sekundę" -#: src/main/help.c:372 src/main/help.c:381 +#: src/main/help.c:375 src/main/help.c:384 msgid "BYTES" msgstr "" -#: src/main/help.c:373 +#: src/main/help.c:376 msgid "use a buffer size of BYTES" msgstr "" -#: src/main/help.c:376 +#: src/main/help.c:379 msgid "never use splice(), always use read/write" msgstr "" -#: src/main/help.c:379 +#: src/main/help.c:382 msgid "skip read errors in input" msgstr "" -#: src/main/help.c:382 +#: src/main/help.c:385 msgid "skip errors in BYTES blocks at a time" msgstr "" -#: src/main/help.c:385 +#: src/main/help.c:388 msgid "stop after --size bytes have been transferred" msgstr "" -#: src/main/help.c:388 +#: src/main/help.c:391 msgid "flush cache to disk after every write" msgstr "" -#: src/main/help.c:391 +#: src/main/help.c:394 msgid "use direct I/O to bypass cache" msgstr "" -#: src/main/help.c:394 +#: src/main/help.c:397 msgid "discard input instead of writing to output" msgstr "" -#: src/main/help.c:397 +#: src/main/help.c:400 msgid "PID" msgstr "" -#: src/main/help.c:398 +#: src/main/help.c:401 msgid "update settings of process PID" msgstr "" -#: src/main/help.c:403 +#: src/main/help.c:406 msgid "save process ID in FILE" msgstr "" -#: src/main/help.c:406 +#: src/main/help.c:409 msgid "PID[:FD]" msgstr "" -#: src/main/help.c:407 +#: src/main/help.c:410 msgid "watch file FD opened by process PID" msgstr "" -#: src/main/help.c:411 +#: src/main/help.c:414 msgid "show this help and exit" msgstr "wyświetl te informacje z pomocą i wyjdź" -#: src/main/help.c:414 +#: src/main/help.c:417 msgid "show version information and exit" msgstr "wyświetl informacje o wersji i wyjdź" -#: src/main/help.c:418 +#: src/main/help.c:421 msgid "write debug logs to FILE" msgstr "" -#: src/main/help.c:443 +#: src/main/help.c:446 #, c-format msgid "Usage: %s [OPTION] [FILE]..." msgstr "Sposób użycia: %s [OPCJA] [PLIK]..." -#: src/main/help.c:454 +#: src/main/help.c:457 msgid "" "Concatenate FILE(s), or standard input, to standard output, with monitoring." msgstr "" "Łączenie PLIK(ów) lub wejścia standardowego, do wyjścia standardowego z " "monitoringiem." -#: src/main/help.c:591 +#: src/main/help.c:594 #, c-format msgid "Please report any bugs to: %s" msgstr "Proszę przesyłać zgłoszenia błędów do %s" @@ -280,59 +284,59 @@ msgstr "" msgid "failed to determine size of block device" msgstr "" -#: src/main/options.c:335 +#: src/main/options.c:336 msgid "option structure allocation failed" msgstr "nie udało się zaalokować struktur opcji" -#: src/main/options.c:354 +#: src/main/options.c:355 msgid "option structure argv allocation failed" msgstr "nie udało się zaalokować struktur opcji argv" -#: src/main/options.c:416 +#: src/main/options.c:417 msgid "integer argument expected" msgstr "" -#: src/main/options.c:427 +#: src/main/options.c:428 msgid "numeric argument expected" msgstr "" -#: src/main/options.c:438 +#: src/main/options.c:439 msgid "process ID or pid:fd pair expected" msgstr "" -#: src/main/options.c:445 +#: src/main/options.c:446 msgid "invalid process ID" msgstr "" -#: src/main/options.c:651 +#: src/main/options.c:655 #, c-format msgid "Try `%s --help' for more information." msgstr "Spróbuj `%s --help' by uzyskać więcej informacji" -#: src/main/options.c:653 +#: src/main/options.c:657 #, c-format msgid "Try `%s -h' for more information." msgstr "Spróbuj `%s -h' by uzyskać więcej informacji" -#: src/main/options.c:684 +#: src/main/options.c:688 msgid "" "cannot use line mode or transfer modifier options when watching file " "descriptors" msgstr "" -#: src/main/options.c:693 +#: src/main/options.c:697 msgid "cannot use cursor positioning when watching file descriptors" msgstr "" -#: src/main/options.c:702 +#: src/main/options.c:706 msgid "cannot use remote control when watching file descriptors" msgstr "" -#: src/main/options.c:711 +#: src/main/options.c:715 msgid "cannot transfer files when watching file descriptors" msgstr "" -#: src/main/options.c:726 +#: src/main/options.c:730 msgid "not available on systems without /proc/self/fdinfo" msgstr "" @@ -385,35 +389,37 @@ msgstr "" msgid "yzafpnum KMGTPEZY" msgstr "" -#: src/pv/display.c:653 src/pv/transfer.c:970 +#: src/pv/display.c:661 src/pv/transfer.c:970 msgid "buffer allocation failed" msgstr "nie udało się zaalokować bufora" -#: src/pv/display.c:789 +#: src/pv/display.c:790 msgid "b" msgstr "" -#: src/pv/display.c:792 src/pv/transfer.c:602 +#: src/pv/display.c:793 src/pv/transfer.c:602 msgid "B" msgstr "B" -#: src/pv/display.c:836 src/pv/display.c:851 src/pv/loop.c:418 +#: src/pv/display.c:837 src/pv/display.c:852 src/pv/display.c:1071 +#: src/pv/loop.c:418 msgid "b/s" msgstr "" -#: src/pv/display.c:840 src/pv/display.c:855 +#: src/pv/display.c:841 src/pv/display.c:856 src/pv/display.c:1075 msgid "/s" msgstr "/s" -#: src/pv/display.c:840 src/pv/display.c:855 src/pv/loop.c:418 +#: src/pv/display.c:841 src/pv/display.c:856 src/pv/display.c:1075 +#: src/pv/loop.c:418 msgid "B/s" msgstr "B/s" -#: src/pv/display.c:883 src/pv/display.c:887 +#: src/pv/display.c:884 src/pv/display.c:888 msgid "ETA" msgstr "ETA" -#: src/pv/display.c:953 +#: src/pv/display.c:954 msgid "FIN" msgstr "" @@ -466,7 +472,7 @@ msgstr "" msgid "history structure allocation failed" msgstr "" -#: src/pv/state.c:465 src/pv/state.c:476 +#: src/pv/state.c:470 src/pv/state.c:481 msgid "file list allocation failed" msgstr "" diff --git a/po/pt.po b/po/pt.po index 4f4187f..6f0d2ee 100644 --- a/po/pt.po +++ b/po/pt.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: pv@ivarch.com\n" -"POT-Creation-Date: 2024-10-04 19:39+0100\n" +"POT-Creation-Date: 2024-10-04 22:08+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -39,7 +39,7 @@ msgstr "exibe a taxa de transferência" msgid "show data transfer average rate counter" msgstr "exibe o contador da taxa média de transferência de dados" -#: src/main/help.c:301 src/main/help.c:335 src/main/help.c:347 +#: src/main/help.c:301 src/main/help.c:335 src/main/help.c:350 msgid "SEC" msgstr "" @@ -108,146 +108,150 @@ msgid "set estimated data size to SIZE bytes" msgstr "seta a quantidade estimada de dados em SIZE bytes" #: src/main/help.c:342 +msgid "if size unknown, show rate vs max rate" +msgstr "" + +#: src/main/help.c:345 msgid "count lines instead of bytes" msgstr "contar linhas em vez de bytes" -#: src/main/help.c:345 +#: src/main/help.c:348 msgid "lines are null-terminated" msgstr "linhas são terminadas em nulo" -#: src/main/help.c:348 +#: src/main/help.c:351 msgid "update every SEC seconds" msgstr "atualiza informações a cada SEC segundos" -#: src/main/help.c:350 +#: src/main/help.c:353 msgid "WIDTH" msgstr "" -#: src/main/help.c:351 +#: src/main/help.c:354 msgid "assume terminal is WIDTH characters wide" msgstr "presuma que o terminal tem WIDTH caracteres de largura" -#: src/main/help.c:353 +#: src/main/help.c:356 msgid "HEIGHT" msgstr "" -#: src/main/help.c:354 +#: src/main/help.c:357 msgid "assume terminal is HEIGHT rows high" msgstr "presuma que o terminal tem HEIGHT caracteres de altura" -#: src/main/help.c:356 +#: src/main/help.c:359 msgid "NAME" msgstr "" -#: src/main/help.c:357 +#: src/main/help.c:360 msgid "prefix visual information with NAME" msgstr "exibe NAME antes das demais informações" -#: src/main/help.c:360 +#: src/main/help.c:363 msgid "output even if standard error is not a terminal" msgstr "gera dados mesmo que a saída de erro seja redirecionada" -#: src/main/help.c:363 +#: src/main/help.c:366 msgid "use cursor positioning escape sequences" msgstr "utiliza caracteres de escape para posicionar o cursor" -#: src/main/help.c:366 src/main/help.c:402 src/main/help.c:417 +#: src/main/help.c:369 src/main/help.c:405 src/main/help.c:420 msgid "FILE" msgstr "" -#: src/main/help.c:367 +#: src/main/help.c:370 msgid "write output to FILE instead of stdout" msgstr "" -#: src/main/help.c:369 +#: src/main/help.c:372 msgid "RATE" msgstr "" -#: src/main/help.c:370 +#: src/main/help.c:373 msgid "limit transfer to RATE bytes per second" msgstr "limita a transferência a RATE bytes por segundo" -#: src/main/help.c:372 src/main/help.c:381 +#: src/main/help.c:375 src/main/help.c:384 msgid "BYTES" msgstr "" -#: src/main/help.c:373 +#: src/main/help.c:376 msgid "use a buffer size of BYTES" msgstr "use um tamanho de buffer de BYTES" -#: src/main/help.c:376 +#: src/main/help.c:379 msgid "never use splice(), always use read/write" msgstr "nunca use splice(), sempre use read/write" -#: src/main/help.c:379 +#: src/main/help.c:382 msgid "skip read errors in input" msgstr "ignorar erros de leitura em entrada" -#: src/main/help.c:382 +#: src/main/help.c:385 msgid "skip errors in BYTES blocks at a time" msgstr "" -#: src/main/help.c:385 +#: src/main/help.c:388 msgid "stop after --size bytes have been transferred" msgstr "parar após --size bytes terem sido transferidos" -#: src/main/help.c:388 +#: src/main/help.c:391 msgid "flush cache to disk after every write" msgstr "" -#: src/main/help.c:391 +#: src/main/help.c:394 msgid "use direct I/O to bypass cache" msgstr "" -#: src/main/help.c:394 +#: src/main/help.c:397 msgid "discard input instead of writing to output" msgstr "" -#: src/main/help.c:397 +#: src/main/help.c:400 msgid "PID" msgstr "" -#: src/main/help.c:398 +#: src/main/help.c:401 msgid "update settings of process PID" msgstr "atualizar as configurações do processo PID" -#: src/main/help.c:403 +#: src/main/help.c:406 msgid "save process ID in FILE" msgstr "salvar ID do processo em FILE" -#: src/main/help.c:406 +#: src/main/help.c:409 msgid "PID[:FD]" msgstr "" -#: src/main/help.c:407 +#: src/main/help.c:410 msgid "watch file FD opened by process PID" msgstr "assistir arquivo FD aberto pelo processo PID" -#: src/main/help.c:411 +#: src/main/help.c:414 msgid "show this help and exit" msgstr "exibe esta tela de ajuda e termina" -#: src/main/help.c:414 +#: src/main/help.c:417 msgid "show version information and exit" msgstr "exibe a versão e termina" -#: src/main/help.c:418 +#: src/main/help.c:421 msgid "write debug logs to FILE" msgstr "" -#: src/main/help.c:443 +#: src/main/help.c:446 #, c-format msgid "Usage: %s [OPTION] [FILE]..." msgstr "Uso: %s [OPÇÕES] [ARQUIVOS]..." -#: src/main/help.c:454 +#: src/main/help.c:457 msgid "" "Concatenate FILE(s), or standard input, to standard output, with monitoring." msgstr "" "Concatena ARQUIVO(s) ou a entrada padrão e grava na saída padrão, com " "monitoramento." -#: src/main/help.c:591 +#: src/main/help.c:594 #, c-format msgid "Please report any bugs to: %s" msgstr "Por favor, reporte quaisquer defeitos para %s" @@ -280,41 +284,41 @@ msgstr "" msgid "failed to determine size of block device" msgstr "" -#: src/main/options.c:335 +#: src/main/options.c:336 msgid "option structure allocation failed" msgstr "erro na alocação da estrutura de opções" -#: src/main/options.c:354 +#: src/main/options.c:355 msgid "option structure argv allocation failed" msgstr "erro na alocação da estrutura de opções argv" -#: src/main/options.c:416 +#: src/main/options.c:417 msgid "integer argument expected" msgstr "argumento inteiro esperado" -#: src/main/options.c:427 +#: src/main/options.c:428 msgid "numeric argument expected" msgstr "argumento numérico esperado" -#: src/main/options.c:438 +#: src/main/options.c:439 msgid "process ID or pid:fd pair expected" msgstr "ID do processo ou par pid:fd esperado" -#: src/main/options.c:445 +#: src/main/options.c:446 msgid "invalid process ID" msgstr "ID de processo inválido" -#: src/main/options.c:651 +#: src/main/options.c:655 #, c-format msgid "Try `%s --help' for more information." msgstr "Tente `%s --help' para maiores informações." -#: src/main/options.c:653 +#: src/main/options.c:657 #, c-format msgid "Try `%s -h' for more information." msgstr "Tente `%s -h' para maiores informações." -#: src/main/options.c:684 +#: src/main/options.c:688 msgid "" "cannot use line mode or transfer modifier options when watching file " "descriptors" @@ -322,21 +326,21 @@ msgstr "" "não pode usar o modo de linha ou opções de modificador de transferência ao " "assistir os descritores de arquivo" -#: src/main/options.c:693 +#: src/main/options.c:697 msgid "cannot use cursor positioning when watching file descriptors" msgstr "" "não pode usar o posicionamento do cursor ao observar os descritores de " "arquivo" -#: src/main/options.c:702 +#: src/main/options.c:706 msgid "cannot use remote control when watching file descriptors" msgstr "não pode usar o controle remoto ao assistir os descritores de arquivo" -#: src/main/options.c:711 +#: src/main/options.c:715 msgid "cannot transfer files when watching file descriptors" msgstr "não pode transferir arquivos ao assistir descritores de arquivo" -#: src/main/options.c:726 +#: src/main/options.c:730 msgid "not available on systems without /proc/self/fdinfo" msgstr "não disponível em sistemas sem /proc/self/fdinfo" @@ -388,35 +392,37 @@ msgstr "" msgid "yzafpnum KMGTPEZY" msgstr "" -#: src/pv/display.c:653 src/pv/transfer.c:970 +#: src/pv/display.c:661 src/pv/transfer.c:970 msgid "buffer allocation failed" msgstr "erro alocando o buffer" -#: src/pv/display.c:789 +#: src/pv/display.c:790 msgid "b" msgstr "" -#: src/pv/display.c:792 src/pv/transfer.c:602 +#: src/pv/display.c:793 src/pv/transfer.c:602 msgid "B" msgstr "" -#: src/pv/display.c:836 src/pv/display.c:851 src/pv/loop.c:418 +#: src/pv/display.c:837 src/pv/display.c:852 src/pv/display.c:1071 +#: src/pv/loop.c:418 msgid "b/s" msgstr "" -#: src/pv/display.c:840 src/pv/display.c:855 +#: src/pv/display.c:841 src/pv/display.c:856 src/pv/display.c:1075 msgid "/s" msgstr "" -#: src/pv/display.c:840 src/pv/display.c:855 src/pv/loop.c:418 +#: src/pv/display.c:841 src/pv/display.c:856 src/pv/display.c:1075 +#: src/pv/loop.c:418 msgid "B/s" msgstr "B/s" -#: src/pv/display.c:883 src/pv/display.c:887 +#: src/pv/display.c:884 src/pv/display.c:888 msgid "ETA" msgstr "ETA" -#: src/pv/display.c:953 +#: src/pv/display.c:954 msgid "FIN" msgstr "" @@ -468,7 +474,7 @@ msgstr "" msgid "history structure allocation failed" msgstr "" -#: src/pv/state.c:465 src/pv/state.c:476 +#: src/pv/state.c:470 src/pv/state.c:481 msgid "file list allocation failed" msgstr "" diff --git a/src/include/options.h b/src/include/options.h index a793039..b2f5412 100644 --- a/src/include/options.h +++ b/src/include/options.h @@ -66,6 +66,7 @@ struct opts_s { bool cursor; /* whether to use cursor positioning */ bool numeric; /* numeric output only */ bool wait; /* wait for transfer before display */ + bool rate_gauge; /* if size unknown, show rate vs max rate */ bool linemode; /* count lines instead of bytes */ bool null_terminated_lines; /* lines are null-terminated */ bool no_display; /* do nothing other than pipe data */ diff --git a/src/include/pv-internal.h b/src/include/pv-internal.h index 05d7708..865f630 100644 --- a/src/include/pv-internal.h +++ b/src/include/pv-internal.h @@ -123,6 +123,7 @@ struct pvstate_s { bool cursor; /* use cursor positioning */ bool numeric; /* numeric output only */ bool wait; /* wait for data before display */ + bool rate_gauge; /* if size unknown, show rate vs max rate */ bool linemode; /* count lines instead of bytes */ bool bits; /* report bits instead of bytes */ bool decimal_units; /* use decimal prefixes */ diff --git a/src/include/pv.h b/src/include/pv.h index 37ad063..cfc9f6f 100644 --- a/src/include/pv.h +++ b/src/include/pv.h @@ -183,6 +183,7 @@ extern void pv_state_show_stats_set(pvstate_t, bool); extern void pv_state_numeric_set(pvstate_t, bool); extern void pv_state_wait_set(pvstate_t, bool); extern void pv_state_delay_start_set(pvstate_t, double); +extern void pv_state_rate_gauge_set(pvstate_t, bool); extern void pv_state_linemode_set(pvstate_t, bool); extern void pv_state_bits_set(pvstate_t, bool); extern void pv_state_decimal_units_set(pvstate_t, bool); diff --git a/src/main/help.c b/src/main/help.c index 4c9dc80..eda41ae 100644 --- a/src/main/help.c +++ b/src/main/help.c @@ -338,6 +338,9 @@ void display_help(void) { "-s", "--size", N_("SIZE"), N_("set estimated data size to SIZE bytes"), { 0, 0, 0, 0} }, + { "-g", "--gauge", NULL, + N_("if size unknown, show rate vs max rate"), + { 0, 0, 0, 0} }, { "-l", "--line-mode", NULL, N_("count lines instead of bytes"), { 0, 0, 0, 0} }, diff --git a/src/main/main.c b/src/main/main.c index 213c418..f3034e5 100644 --- a/src/main/main.c +++ b/src/main/main.c @@ -310,6 +310,7 @@ int main(int argc, char **argv) pv_state_numeric_set(state, opts->numeric); pv_state_wait_set(state, opts->wait); pv_state_delay_start_set(state, opts->delay_start); + pv_state_rate_gauge_set(state, opts->rate_gauge); pv_state_linemode_set(state, opts->linemode); pv_state_bits_set(state, opts->bits); pv_state_decimal_units_set(state, opts->decimal_units); diff --git a/src/main/options.c b/src/main/options.c index 91e5635..c54c9bb 100644 --- a/src/main/options.c +++ b/src/main/options.c @@ -283,6 +283,7 @@ opts_t opts_parse(unsigned int argc, char **argv) { "wait", 0, NULL, (int) 'W' }, { "delay-start", 1, NULL, (int) 'D' }, { "size", 1, NULL, (int) 's' }, + { "gauge", 0, NULL, (int) 'g' }, { "line-mode", 0, NULL, (int) 'l' }, { "null", 0, NULL, (int) '0' }, { "interval", 1, NULL, (int) 'i' }, @@ -313,7 +314,7 @@ opts_t opts_parse(unsigned int argc, char **argv) /*@+nullassign@ */ int option_index = 0; #endif /* HAVE_GETOPT_LONG */ - char *short_options = "hVpteIrab8kTA:fvnqcWD:s:l0i:w:H:N:F:L:B:CEZ:SYKXR:P:d:m:o:" + char *short_options = "hVpteIrab8kTA:fvnqcWD:s:gl0i:w:H:N:F:L:B:CEZ:SYKXR:P:d:m:o:" #ifdef ENABLE_DEBUGGING "!:" #endif @@ -546,6 +547,9 @@ opts_t opts_parse(unsigned int argc, char **argv) } } break; + case 'g': + opts->rate_gauge = true; + break; case 'l': opts->linemode = true; break; diff --git a/src/pv/display.c b/src/pv/display.c index 0dbbe2a..8e4fc2b 100644 --- a/src/pv/display.c +++ b/src/pv/display.c @@ -607,6 +607,7 @@ bool pv_format(pvstate_t state, bool final) size_t segment; size_t new_display_string_len; const char *formatstr; + pv__transfercount_t count_type; /* Quick safety check - state must exist. */ if (NULL == state) @@ -626,6 +627,13 @@ bool pv_format(pvstate_t state, bool final) if (NULL == formatstr) return false; + /* Determine the type of thing being counted for transfer, rate, etc. */ + count_type = PV_TRANSFERCOUNT_BYTES; + if (state->control.linemode) + count_type = PV_TRANSFERCOUNT_LINES; + else if (state->control.decimal_units) + count_type = PV_TRANSFERCOUNT_DECBYTES; + /* * Reallocate output buffer if width changes. */ @@ -745,7 +753,6 @@ bool pv_format(pvstate_t state, bool final) time_t then; struct tm *time_ptr; char *time_format; - pv__transfercount_t count_type; if (!state->display.component[component_type].required) continue; @@ -766,12 +773,6 @@ bool pv_format(pvstate_t state, bool final) component_content[0] = '\0'; component_buf_size = PV_SIZEOF_COMPONENT_STR; - count_type = PV_TRANSFERCOUNT_BYTES; - if (state->control.linemode) - count_type = PV_TRANSFERCOUNT_LINES; - else if (state->control.decimal_units) - count_type = PV_TRANSFERCOUNT_DECBYTES; - switch (component_type) { case PV_COMPONENT_STRING: @@ -1034,27 +1035,54 @@ bool pv_format(pvstate_t state, bool final) if (state->display.component[PV_COMPONENT_PROGRESS].required) { char *component_content; size_t component_buf_size; - char pct[16]; /* flawfinder: ignore - only populated by pv_snprintf(). */ + char after_bar[32]; /* flawfinder: ignore - only populated by pv_snprintf(). */ int available_width, bar_length, pad_count; component_content = state->display.component[PV_COMPONENT_PROGRESS].content; component_content[0] = '\0'; component_buf_size = PV_SIZEOF_COMPONENT_STR; - memset(pct, 0, sizeof(pct)); + memset(after_bar, 0, sizeof(after_bar)); - /* The opening of the bar area. */ - (void) pv_snprintf(component_content, component_buf_size, "["); + if (state->control.size > 0 || state->control.rate_gauge) { + /* + * Known size, or rate gauge mode. Show a bar, and + * a percentage (size) or max rate (gauge). + */ + size_t after_bar_width; + int bar_percentage; - if (state->control.size > 0) { - /* Known size; show a bar and a percentage. */ - size_t pct_width; + if (state->control.size > 0) { + /* Percentage of data transferred. */ + bar_percentage = state->calc.percentage; + (void) pv_snprintf(after_bar, sizeof(after_bar), " %3ld%%", bar_percentage); + } else { + /* Current rate vs max rate. */ + bar_percentage = 0; + if (state->calc.rate_max > 0) { + bar_percentage = + (int) (100.0 * state->calc.transfer_rate / state->calc.rate_max); + } - (void) pv_snprintf(pct, sizeof(pct), "%3ld%%", state->calc.percentage); - pct_width = strlen(pct); /* flawfinder: ignore */ + /*@-mustfreefresh @ */ + if (state->control.bits && !state->control.linemode) { + /* bits per second */ + pv__sizestr(after_bar, sizeof(after_bar), "/%s", + 8.0 * state->calc.rate_max, "", _("b/s"), count_type); + } else { + /* bytes or lines per second */ + pv__sizestr(after_bar, sizeof(after_bar), + "/%s", state->calc.rate_max, _("/s"), _("B/s"), count_type); + } + /*@+mustfreefresh @ */ + /* splint: see above about gettext(). */ + } + + after_bar_width = strlen(after_bar); /* flawfinder: ignore */ /* flawfinder: always \0-terminated by pv_snprintf() and the earlier memset(). */ - available_width = (int) (state->control.width) - static_portion_size - (int) (pct_width) - 3; + available_width = + (int) (state->control.width) - static_portion_size - (int) (after_bar_width) - 2; if (available_width < 0) available_width = 0; @@ -1062,8 +1090,11 @@ bool pv_format(pvstate_t state, bool final) if (available_width > (int) (component_buf_size) - 16) available_width = (int) (component_buf_size - 16); + /* The opening of the bar area. */ + (void) pv_snprintf(component_content, component_buf_size, "["); + /* The bar portion. */ - bar_length = (int) ((available_width * state->calc.percentage) / 100 - 1); + bar_length = (int) ((available_width * bar_percentage) / 100 - 1); for (pad_count = 0; pad_count < bar_length; pad_count++) { if (pad_count < available_width) (void) pv_strlcat(component_content, "=", component_buf_size); @@ -1081,8 +1112,8 @@ bool pv_format(pvstate_t state, bool final) } /* The closure of the bar area, and the percentage. */ - (void) pv_strlcat(component_content, "] ", component_buf_size); - (void) pv_strlcat(component_content, pct, component_buf_size); + (void) pv_strlcat(component_content, "]", component_buf_size); + (void) pv_strlcat(component_content, after_bar, component_buf_size); } else { /* Unknown size; show a moving indicator. */ @@ -1109,6 +1140,9 @@ bool pv_format(pvstate_t state, bool final) if (indicator_position > 100) indicator_position = 200 - indicator_position; + /* The opening of the bar area. */ + (void) pv_snprintf(component_content, component_buf_size, "["); + /* The spaces before the indicator. */ for (pad_count = 0; pad_count < (available_width * indicator_position) / 100; pad_count++) { if (pad_count < available_width) diff --git a/src/pv/state.c b/src/pv/state.c index 20fe133..3938037 100644 --- a/src/pv/state.c +++ b/src/pv/state.c @@ -270,6 +270,11 @@ void pv_state_delay_start_set(pvstate_t state, double val) state->control.delay_start = val; } +void pv_state_rate_gauge_set(pvstate_t state, bool val) +{ + state->control.rate_gauge = val; +} + void pv_state_linemode_set(pvstate_t state, bool val) { state->control.linemode = val;