Add a "--gauge" option which alters the progress bar to show the current rate as a percentage of the max rate seen, if the size is unknown (#46).

This commit is contained in:
Andrew Wood
2024-10-04 22:15:14 +01:00
parent fbe726e4c4
commit c548d1f2d8
15 changed files with 361 additions and 255 deletions
+3
View File
@@ -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} },
+1
View File
@@ -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);
+5 -1
View File
@@ -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;