diff --git a/hyptop/hyptop.8 b/hyptop/hyptop.8 index 49235bb5..75e63dd6 100644 --- a/hyptop/hyptop.8 +++ b/hyptop/hyptop.8 @@ -115,6 +115,13 @@ represent data for one system in one iteration. .PP This option implies the "\-\-batch-mode" option. .RE +.BR "\-\-all" +.RS +Use this option with the "--format" option to include fields without valid +values in the output. Fields without valid values are omitted from the output +by default. When you use the "--all" option, the invalid values are included +and shown as "null". +.RE .TP .BR "\-d " " or " "\-\-delay=" Specifies the delay between screen updates. diff --git a/hyptop/hyptop.c b/hyptop/hyptop.c index a7fe6f8f..7b909588 100644 --- a/hyptop/hyptop.c +++ b/hyptop/hyptop.c @@ -229,10 +229,10 @@ static void l_fmt_init(void) if (!g.o.format_specified) return; - if (g.o.format == FMT_CSV) { + if (g.o.format == FMT_CSV) flags |= FMT_QUOTEALL; + if (g.o.format == FMT_CSV || g.o.format_all) flags |= FMT_KEEPINVAL; - } if (g.o.format == FMT_JSON || g.o.format == FMT_JSONSEQ) flags |= FMT_HANDLEINT; util_fmt_init(stdout, g.o.format, flags, 1); diff --git a/hyptop/hyptop.h b/hyptop/hyptop.h index 7eb84241..bd5b5ba4 100644 --- a/hyptop/hyptop.h +++ b/hyptop/hyptop.h @@ -55,6 +55,7 @@ struct hyptop_opts { unsigned int win_specified; unsigned int batch_mode_specified; unsigned int format_specified; + unsigned int format_all; enum util_fmt_t format; unsigned int iterations_specified; unsigned int iterations; diff --git a/hyptop/opts.c b/hyptop/opts.c index c08d742c..ca182069 100644 --- a/hyptop/opts.c +++ b/hyptop/opts.c @@ -42,6 +42,8 @@ static char HELP_TEXT[] = "-t, --cpu-types TYPE[,..] CPU types used for time calculations\n" "-b, --batch-mode Use batch mode (no curses)\n" " --format FORMAT Output format (" FMT_TYPE_NAMES "), implies -b\n" +" --all Include omitted fields (with values of null)\n" +" in the output of --format.\n" "-d, --delay SECONDS Delay time between screen updates\n" "-m, --smt-factor FACTOR Machine generation dependent SMT speedup factor.\n" "-n, --iterations NUMBER Number of iterations before ending\n"; @@ -50,6 +52,7 @@ static char HELP_TEXT[] = * Options with long-name only */ #define OPT_FORMAT 256 /* --format */ +#define OPT_FORMAT_ALL 261 /* --all*/ /* * Options with underscore to keep compatibility @@ -321,6 +324,15 @@ static void l_format_set(const char *str) g.o.format = fmt; } +/* + * Set the "--all" option to display omitted null values + * while using "--format" + */ +static void l_format_all_set(void) +{ + g.o.format_all = 1; +} + /* * Make option consisteny checks at end of command line parsing */ @@ -328,6 +340,8 @@ static void l_parse_finish(void) { if (g.o.iterations_specified && g.o.iterations == 0) hyptop_exit(0); + if (!g.o.format_specified && g.o.format_all) + ERR_EXIT("The --all option requires the -–format option\n"); if (g.o.cur_win != &win_sys) return; if (!win_sys.opts.sys.specified) @@ -349,6 +363,7 @@ void opts_parse(int argc, char *argv[]) { "help", no_argument, NULL, 'h'}, { "batch-mode", no_argument, NULL, 'b'}, { "batch_mode", no_argument, NULL, OPT_BATCH_MODE}, + { "all", no_argument, NULL, OPT_FORMAT_ALL }, { "delay", required_argument, NULL, 'd'}, { "smt-factor", required_argument, NULL, 'm'}, { "smt_factor", required_argument, NULL, OPT_SMT_FACTOR}, @@ -412,6 +427,9 @@ void opts_parse(int argc, char *argv[]) case OPT_FORMAT: l_format_set(optarg); break; + case OPT_FORMAT_ALL: + l_format_all_set(); + break; default: l_std_usage_exit(); }