Add long names to format sequences, such as "%{rate}".

This commit is contained in:
Andrew Wood
2024-12-08 17:16:02 +00:00
parent 838ebcb78f
commit 57149c2d03
12 changed files with 62 additions and 46 deletions
+1
View File
@@ -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)
+16 -15
View File
@@ -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:
+17 -15
View File
@@ -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
+2 -2
View File
@@ -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 <mmatous@users.noreply.translate.codeberg.org>\n"
"Language-Team: Czech <https://translate.codeberg.org/projects/pv/pv/cs/>\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"
+2 -2
View File
@@ -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 <otto@codeberg.org>\n"
"Language-Team: German <https://translate.codeberg.org/projects/pv/pv/de/>\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"
+2 -2
View File
@@ -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 ""
+2 -2
View File
@@ -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 <a-j-wood@users.noreply.translate.codeberg.org>\n"
"Language-Team: French <https://translate.codeberg.org/projects/pv/pv/fr/>\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"
+2 -2
View File
@@ -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 <coralpink@users.noreply.translate.codeberg.org>\n"
"Language-Team: Polish <https://translate.codeberg.org/projects/pv/pv/pl/>\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"
+2 -2
View File
@@ -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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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"
+2 -2
View File
@@ -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 <https://translate.codeberg.org/projects/pv/pv/ru/>\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 "не удалось выделить память для буфера"
+2 -2
View File
@@ -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 <a-j-wood@users.noreply.translate.codeberg.org>\n"
"Language-Team: Turkish <https://translate.codeberg.org/projects/pv/pv/tr/>\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"
+12
View File
@@ -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 }
};