From 57149c2d03ff387e8c62268266cfb0eec3d54afc Mon Sep 17 00:00:00 2001 From: Andrew Wood Date: Sun, 8 Dec 2024 17:16:02 +0000 Subject: [PATCH] Add long names to format sequences, such as "%{rate}". --- docs/NEWS.md | 1 + docs/pv.1 | 31 ++++++++++++++++--------------- docs/pv.1.md | 32 +++++++++++++++++--------------- po/cs.po | 4 ++-- po/de.po | 4 ++-- po/es.po | 4 ++-- po/fr.po | 4 ++-- po/pl.po | 4 ++-- po/pt.po | 4 ++-- po/ru.po | 4 ++-- po/tr.po | 4 ++-- src/pv/display.c | 12 ++++++++++++ 12 files changed, 62 insertions(+), 46 deletions(-) diff --git a/docs/NEWS.md b/docs/NEWS.md index d0a886d..169ec38 100644 --- a/docs/NEWS.md +++ b/docs/NEWS.md @@ -1,6 +1,7 @@ ### UNRELEASED * *feature:* new **--format** sequence "**%nL**", showing the most recent line written (#121) + * *feature:* each **--format** sequence now has a more readable equivalent name, for example "**%r**" can be written as "**%{rate}**" * *fix:* allow **--format** to include "%nA" more than once, with different "n" values (#122) * *fix:* allow **--format** to include "%p" more than once * *fix:* add _configure_ script fallback for **--remote** check when cross-compiling (#120) diff --git a/docs/pv.1 b/docs/pv.1 index 245e907..5974f31 100644 --- a/docs/pv.1 +++ b/docs/pv.1 @@ -471,56 +471,57 @@ Print version information on standard output and exit successfully. Format strings used by \*(lq\fB\-\-format\fR\*(rq and \*(lq\fB\-\-extra\-display\fR\*(rq can contain the following sequences: .TP -.B %p -Progress bar. -Expands to fill the remaining space. +.BR %p ", " %{progress} +Progress bar (suffixed with a percentage if the size is known). Equivalent to \*(lq\fB\-\-progress\fR\*(rq. +Expands to fill the remaining space unless prefixed by a number to set the +width, such as \*(lq\fB%20p\fR\*(rq or \*(lq\fB%20{progress}\fR\*(rq. .TP -.B %t +.BR %t ", " %{timer} Elapsed time. Equivalent to \*(lq\fB\-\-timer\fR\*(rq. .TP -.B %e +.BR %e ", " %{eta} ETA as time remaining. Equivalent to \*(lq\fB\-\-eta\fR\*(rq. .TP -.B %I +.BR %I ", " %{fineta} ETA as local time at which the transfer will finish. Equivalent to \*(lq\fB\-\-fineta\fR\*(rq. .TP -.B %r +.BR %r ", " %{rate} Current data transfer rate. Equivalent to \*(lq\fB\-\-rate\fR\*(rq. .TP -.B %a +.BR %a ", " %{average-rate} Average data transfer rate. Equivalent to \*(lq\fB\-\-average\-rate\fR\*(rq. .TP -.B %b +.BR %b ", " %{bytes} ", " %{transferred} Bytes transferred so far (or lines if \*(lq\fB\-\-line\-mode\fR\*(rq was specified). Equivalent to \*(lq\fB\-\-bytes\fR\*(rq. If \*(lq\fB\-\-bits\fR\*(rq was specified, \*(lq\fB%b\fR\*(rq shows the bits transferred so far, not bytes. .TP -.B %T +.BR %T ", " %{buffer-percent} Percentage of the transfer buffer in use. Equivalent to \*(lq\fB\-\-buffer\-percent\fR\*(rq. Displays \*(lq{\-\-\-\-}\*(rq if the transfer is being done with \fBsplice\fR(2), since splicing to or from pipes does not use the buffer. .TP -.B %nA +.BR %nA ", " %n{last-written} Show the last \fIn\fR bytes written (for example, \*(lq\fB%16A\fR\*(rq shows the last 16 bytes). Shows only dots if the transfer is being done with \fBsplice\fR(2), since splicing to or from pipes does not use the buffer. .TP -.B %nL +.BR %nL ", " %n{previous-line} Show the first \fIn\fR bytes of the most recently written line (for example, \*(lq\fB%40L\fR\*(rq shows the first 40 bytes). If no \fIn\fR is given, then this expands to fill the available space. Shows only spaces if the transfer is being done with \fBsplice\fR(2). .TP -.B %N +.BR %N ", " %{name} Show the name prefix given by \*(lq\fB\-\-name\fR\*(rq. Padded to 9 characters with spaces, and suffixed with \*(lq:\*(rq. .TP @@ -529,8 +530,8 @@ A single \*(lq%\*(rq. .PP Any other contents are reproduced in the progress display as-is. .PP -The format string equivalent of turning on all display switches is -\*(lq\fB%N\~%b\~%T\~%t\~%r\~%a\~%p\~%e\~%I\~%8A\fR\*(rq. +The format string equivalent of the default display switches is +\*(lq\fB%b\~%t\~%r\~%p\~%e\fR\*(rq. .\" .SH EXAMPLES Some suggested common switch combinations: diff --git a/docs/pv.1.md b/docs/pv.1.md index 17ca8be..fbef586 100644 --- a/docs/pv.1.md +++ b/docs/pv.1.md @@ -420,60 +420,62 @@ are explicitly switched on will be shown. Format strings used by "**\--format**" and "**\--extra-display**" can contain the following sequences: -**%p** +**%p**, **%{progress}** -: Progress bar. Expands to fill the remaining space. Equivalent to - "**\--progress**". +: Progress bar (suffixed with a percentage if the size is known). + Equivalent to "**\--progress**". Expands to fill the remaining space + unless prefixed by a number to set the width, such as "**%20p**" or + "**%20{progress}**". -**%t** +**%t**, **%{timer}** : Elapsed time. Equivalent to "**\--timer**". -**%e** +**%e**, **%{eta}** : ETA as time remaining. Equivalent to "**\--eta**". -**%I** +**%I**, **%{fineta}** : ETA as local time at which the transfer will finish. Equivalent to "**\--fineta**". -**%r** +**%r**, **%{rate}** : Current data transfer rate. Equivalent to "**\--rate**". -**%a** +**%a**, **%{average-rate}** : Average data transfer rate. Equivalent to "**\--average-rate**". -**%b** +**%b**, **%{bytes}**, **%{transferred}** : Bytes transferred so far (or lines if "**\--line-mode**" was specified). Equivalent to "**\--bytes**". If "**\--bits**" was specified, "**%b**" shows the bits transferred so far, not bytes. -**%T** +**%T**, **%{buffer-percent}** : Percentage of the transfer buffer in use. Equivalent to "**\--buffer-percent**". Displays "{\-\-\--}" if the transfer is being done with **splice**(2), since splicing to or from pipes does not use the buffer. -**%nA** +**%nA**, **%n{last-written}** : Show the last *n* bytes written (for example, "**%16A**" shows the last 16 bytes). Shows only dots if the transfer is being done with **splice**(2), since splicing to or from pipes does not use the buffer. -**%nL** +**%nL**, **%n{previous-line}** : Show the first *n* bytes of the most recently written line (for example, "**%40L**" shows the first 40 bytes). If no *n* is given, then this expands to fill the available space. Shows only spaces if the transfer is being done with **splice**(2). -**%N** +**%N**, **%{name}** : Show the name prefix given by "**\--name**". Padded to 9 characters with spaces, and suffixed with ":". @@ -484,8 +486,8 @@ contain the following sequences: Any other contents are reproduced in the progress display as-is. -The format string equivalent of turning on all display switches is -"**%N %b %T %t %r %a %p %e %I %8A**". +The format string equivalent of the default display switches is +"**%b %t %r %p %e**". # EXAMPLES diff --git a/po/cs.po b/po/cs.po index f31d8bc..32ce2f8 100644 --- a/po/cs.po +++ b/po/cs.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Report-Msgid-Bugs-To: pv@ivarch.com\n" -"POT-Creation-Date: 2024-12-08 16:17+0000\n" +"POT-Creation-Date: 2024-12-08 17:13+0000\n" "PO-Revision-Date: 2024-10-13 20:43+0000\n" "Last-Translator: mmatous \n" "Language-Team: Czech \n" @@ -433,7 +433,7 @@ msgstr "b" msgid "B" msgstr "B" -#: src/pv/display.c:1485 src/pv/transfer.c:1064 +#: src/pv/display.c:1497 src/pv/transfer.c:1064 msgid "buffer allocation failed" msgstr "selhala alokace vyrovnávací paměti" diff --git a/po/de.po b/po/de.po index 58baa1e..92020c6 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-12-08 16:17+0000\n" +"POT-Creation-Date: 2024-12-08 17:13+0000\n" "PO-Revision-Date: 2024-10-13 20:43+0000\n" "Last-Translator: fnetX \n" "Language-Team: German \n" @@ -456,7 +456,7 @@ msgstr "b" msgid "B" msgstr "B" -#: src/pv/display.c:1485 src/pv/transfer.c:1064 +#: src/pv/display.c:1497 src/pv/transfer.c:1064 msgid "buffer allocation failed" msgstr "Speicherzuweisung für den Puffer fehlgeschlagen" diff --git a/po/es.po b/po/es.po index eda3ac2..74dfab3 100644 --- a/po/es.po +++ b/po/es.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Report-Msgid-Bugs-To: pv@ivarch.com\n" -"POT-Creation-Date: 2024-12-08 16:17+0000\n" +"POT-Creation-Date: 2024-12-08 17:13+0000\n" "Language: es\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -425,7 +425,7 @@ msgstr "" msgid "B" msgstr "" -#: src/pv/display.c:1485 src/pv/transfer.c:1064 +#: src/pv/display.c:1497 src/pv/transfer.c:1064 msgid "buffer allocation failed" msgstr "" diff --git a/po/fr.po b/po/fr.po index f5b3946..23ad69d 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-12-08 16:17+0000\n" +"POT-Creation-Date: 2024-12-08 17:13+0000\n" "PO-Revision-Date: 2024-10-12 11:13+0000\n" "Last-Translator: a-j-wood \n" "Language-Team: French \n" @@ -460,7 +460,7 @@ msgstr "" msgid "B" msgstr "O" -#: src/pv/display.c:1485 src/pv/transfer.c:1064 +#: src/pv/display.c:1497 src/pv/transfer.c:1064 msgid "buffer allocation failed" msgstr "échec de l'allocation de mémoire tampon" diff --git a/po/pl.po b/po/pl.po index 6bede44..07ee058 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-12-08 16:17+0000\n" +"POT-Creation-Date: 2024-12-08 17:13+0000\n" "PO-Revision-Date: 2024-10-20 14:07+0000\n" "Last-Translator: coralpink \n" "Language-Team: Polish \n" @@ -451,7 +451,7 @@ msgstr "b" msgid "B" msgstr "B" -#: src/pv/display.c:1485 src/pv/transfer.c:1064 +#: src/pv/display.c:1497 src/pv/transfer.c:1064 msgid "buffer allocation failed" msgstr "nie udało się zaalokować bufora" diff --git a/po/pt.po b/po/pt.po index efb4015..b37ec1f 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-12-08 16:17+0000\n" +"POT-Creation-Date: 2024-12-08 17:13+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -439,7 +439,7 @@ msgstr "" msgid "B" msgstr "" -#: src/pv/display.c:1485 src/pv/transfer.c:1064 +#: src/pv/display.c:1497 src/pv/transfer.c:1064 msgid "buffer allocation failed" msgstr "erro alocando o buffer" diff --git a/po/ru.po b/po/ru.po index ac9b022..3c48c50 100644 --- a/po/ru.po +++ b/po/ru.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Report-Msgid-Bugs-To: pv@ivarch.com\n" -"POT-Creation-Date: 2024-12-08 16:17+0000\n" +"POT-Creation-Date: 2024-12-08 17:13+0000\n" "PO-Revision-Date: 2024-10-22 18:07+0000\n" "Last-Translator: 0ko <0ko@users.noreply.translate.codeberg.org>\n" "Language-Team: Russian \n" @@ -434,7 +434,7 @@ msgstr "бит" msgid "B" msgstr "байт" -#: src/pv/display.c:1485 src/pv/transfer.c:1064 +#: src/pv/display.c:1497 src/pv/transfer.c:1064 msgid "buffer allocation failed" msgstr "не удалось выделить память для буфера" diff --git a/po/tr.po b/po/tr.po index af93ae4..dfce8f8 100644 --- a/po/tr.po +++ b/po/tr.po @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: pv 1.8.14\n" "Report-Msgid-Bugs-To: pv@ivarch.com\n" -"POT-Creation-Date: 2024-12-08 16:17+0000\n" +"POT-Creation-Date: 2024-12-08 17:13+0000\n" "PO-Revision-Date: 2024-10-12 23:51+0000\n" "Last-Translator: a-j-wood \n" "Language-Team: Turkish \n" @@ -435,7 +435,7 @@ msgstr "b" msgid "B" msgstr "B" -#: src/pv/display.c:1485 src/pv/transfer.c:1064 +#: src/pv/display.c:1497 src/pv/transfer.c:1064 msgid "buffer allocation failed" msgstr "arabellek tahsisi başarısız oldu" diff --git a/src/pv/display.c b/src/pv/display.c index 4856be9..0b8b3b5 100644 --- a/src/pv/display.c +++ b/src/pv/display.c @@ -1197,16 +1197,28 @@ static struct pvdisplay_component_s { bool dynamic; /* whether it can scale with screen size */ } format_component[] = { { "p", &pv__format_progress, true }, + { "{progress}", &pv__format_progress, true }, { "t", &pv__format_timer, false }, + { "{timer}", &pv__format_timer, false }, { "e", &pv__format_eta, false }, + { "{eta}", &pv__format_eta, false }, { "I", &pv__format_fineta, false }, + { "{fineta}", &pv__format_fineta, false }, { "r", &pv__format_rate, false }, + { "{rate}", &pv__format_rate, false }, { "a", &pv__format_average_rate, false }, + { "{average-rate}", &pv__format_average_rate, false }, { "b", &pv__format_bytes, false }, + { "{bytes}", &pv__format_bytes, false }, + { "{transferred}", &pv__format_bytes, false }, { "T", &pv__format_buffer_percent, false }, + { "{buffer-percent}", &pv__format_buffer_percent, false }, { "A", &pv__format_last_written, false }, + { "{last-written}", &pv__format_last_written, false }, { "L", &pv__format_previous_line, true }, + { "{previous-line}", &pv__format_previous_line, true }, { "N", &pv__format_name, false }, + { "{name}", &pv__format_name, false }, { NULL, NULL, false } };