Skip to content

Commit

Permalink
Add a -q flag to ministat to suppress headers in output, for use with…
Browse files Browse the repository at this point in the history
… -n.

Reviewed by:	jrtc27
Differential Revision: https://reviews.freebsd.org/D33724
MFC after:	2 weeks
  • Loading branch information
rwatson committed Dec 18, 2021
1 parent 1fbcaa1 commit 7776d3c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
6 changes: 5 additions & 1 deletion usr.bin/ministat/ministat.1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down
18 changes: 13 additions & 5 deletions usr.bin/ministat/ministat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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%%",
Expand All @@ -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);
Expand All @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 7776d3c

Please sign in to comment.