From 80358e84f32618a3f211c93706eac446dad8e596 Mon Sep 17 00:00:00 2001 From: Andrew Wood Date: Thu, 2 Apr 2026 23:08:49 +0100 Subject: [PATCH] If no display options are passed and "-M both" is active, set a "ratio" option flag to display the in:out ratio as well (#67). --- src/include/options.h | 1 + src/main/options.c | 3 ++- src/pv/state.c | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/include/options.h b/src/include/options.h index ecf0b23..3997895 100644 --- a/src/include/options.h +++ b/src/include/options.h @@ -93,6 +93,7 @@ struct opts_s { bool rate; /* rate counter flag */ bool average_rate; /* average rate counter flag */ bool bytes; /* bytes transferred flag */ + bool ratio; /* in:out ratio flag */ bool bits; /* report transfer size in bits */ bool decimal_units; /* decimal prefix flag */ bool bufpercent; /* transfer buffer percentage flag */ diff --git a/src/main/options.c b/src/main/options.c index cf85a6f..f8877e7 100644 --- a/src/main/options.c +++ b/src/main/options.c @@ -1290,7 +1290,8 @@ opts_t opts_parse(unsigned int argc, char **argv) opts->eta = true; opts->rate = true; opts->bytes = true; - /* TODO: add ratio format if "-M both" */ + if (PV_SIDE_BOTH == opts->side) + opts->ratio = true; } /* If -Z was given but not -E, pretend one -E was given too. */ diff --git a/src/pv/state.c b/src/pv/state.c index 38f4e9e..298cdd2 100644 --- a/src/pv/state.c +++ b/src/pv/state.c @@ -412,6 +412,8 @@ void pv_state_free(pvstate_t state) /* * Set the formatting string, given a set of old-style formatting options. + * + * TODO: allow opts->ratio to be passed here as well. */ void pv_state_set_format(pvstate_t state, bool progress, bool timer, bool eta, bool fineta, bool rate, bool average_rate, bool bytes, bool bufpercent, size_t lastwritten, /*@null@ */ const char *name)