git: 7776d3ccd16e - main - Add a -q flag to ministat to suppress headers in output, for use with -n.

From: Robert Watson <rwatson_at_FreeBSD.org>
Date: Sun, 02 Jan 2022 22:52:48 UTC
The branch main has been updated by rwatson:

URL: https://cgit.FreeBSD.org/src/commit/?id=7776d3ccd16ec8fd78db34083eb182c2a2d18e26

commit 7776d3ccd16ec8fd78db34083eb182c2a2d18e26
Author:     Robert Watson <rwatson@FreeBSD.org>
AuthorDate: 2021-12-18 20:02:08 +0000
Commit:     Robert Watson <rwatson@FreeBSD.org>
CommitDate: 2021-12-18 22:53:03 +0000

    Add a -q flag to ministat to suppress headers in output, for use with -n.
    
    Reviewed by:    jrtc27
    Differential Revision: https://reviews.freebsd.org/D33724
    MFC after:      2 weeks
---
 usr.bin/ministat/ministat.1 |  6 +++++-
 usr.bin/ministat/ministat.c | 18 +++++++++++++-----
 2 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/usr.bin/ministat/ministat.1 b/usr.bin/ministat/ministat.1
index f713baef8fca..c7a20c75ce24 100644
--- a/usr.bin/ministat/ministat.1
+++ b/usr.bin/ministat/ministat.1
@@ -33,7 +33,7 @@
 .Nd statistics utility
 .Sh SYNOPSIS
 .Nm
-.Op Fl Ans
+.Op Fl Anqs
 .Op Fl C Ar column
 .Op Fl c Ar confidence_level
 .Op Fl d Ar delimiter
@@ -53,6 +53,10 @@ suppress the ASCII-art plot.
 .It Fl n
 Just report the raw statistics of the input, suppress the ASCII-art plot
 and the relative comparisons.
+.It Fl q
+Suppress printing of summary statistics and data-set names; typically for use
+alongside
+.Fl n .
 .It Fl s
 Print the average/median/stddev bars on separate lines in the ASCII-art
 plot, to avoid overlap.
diff --git a/usr.bin/ministat/ministat.c b/usr.bin/ministat/ministat.c
index 3134c4b03928..aa6bc27f89ab 100644
--- a/usr.bin/ministat/ministat.c
+++ b/usr.bin/ministat/ministat.c
@@ -533,7 +533,7 @@ usage(char const *whine)
 
 	fprintf(stderr, "%s\n", whine);
 	fprintf(stderr,
-	    "Usage: ministat [-C column] [-c confidence] [-d delimiter(s)] [-Ans] [-w width] [file [file ...]]\n");
+	    "Usage: ministat [-C column] [-c confidence] [-d delimiter(s)] [-Anqs] [-w width] [file [file ...]]\n");
 	fprintf(stderr, "\tconfidence = {");
 	for (i = 0; i < NCONF; i++) {
 		fprintf(stderr, "%s%g%%",
@@ -545,6 +545,7 @@ usage(char const *whine)
 	fprintf(stderr, "\t-C : column number to extract (starts and defaults to 1)\n");
 	fprintf(stderr, "\t-d : delimiter(s) string, default to \" \\t\"\n");
 	fprintf(stderr, "\t-n : print summary statistics only, no graph/test\n");
+	fprintf(stderr, "\t-q : suppress printing summary-statistics headers and data-set names\n");
 	fprintf(stderr, "\t-s : print avg/median/stddev bars on separate lines\n");
 	fprintf(stderr, "\t-w : width of graph/test output (default 74 or terminal width)\n");
 	exit (2);
@@ -564,6 +565,7 @@ main(int argc, char **argv)
 	int column = 1;
 	int flag_s = 0;
 	int flag_n = 0;
+	int flag_q = 0;
 	int termwidth = 74;
 	int suppress_plot = 0;
 
@@ -578,7 +580,7 @@ main(int argc, char **argv)
 	}
 
 	ci = -1;
-	while ((c = getopt(argc, argv, "AC:c:d:snw:")) != -1)
+	while ((c = getopt(argc, argv, "AC:c:d:snqw:")) != -1)
 		switch (c) {
 		case 'A':
 			suppress_plot = 1;
@@ -608,6 +610,9 @@ main(int argc, char **argv)
 		case 'n':
 			flag_n = 1;
 			break;
+		case 'q':
+			flag_q = 1;
+			break;
 		case 's':
 			flag_s = 1;
 			break;
@@ -664,8 +669,10 @@ main(int argc, char **argv)
 			fclose(setfiles[i]);
 	}
 
-	for (i = 0; i < nds; i++)
-		printf("%c %s\n", symbol[i+1], ds[i]->name);
+	if (!flag_q) {
+		for (i = 0; i < nds; i++)
+			printf("%c %s\n", symbol[i+1], ds[i]->name);
+	}
 
 	if (!flag_n && !suppress_plot) {
 		SetupPlot(termwidth, flag_s, nds);
@@ -675,7 +682,8 @@ main(int argc, char **argv)
 			PlotSet(ds[i], i + 1);
 		DumpPlot();
 	}
-	VitalsHead();
+	if (!flag_q)
+		VitalsHead();
 	Vitals(ds[0], 1);
 	for (i = 1; i < nds; i++) {
 		Vitals(ds[i], i + 1);