From 556368154db41283f9a26b1a5197916a6cc4fadb Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Sat, 19 Oct 2024 16:15:37 -0700 Subject: vmon: wire up the new markers API to vmon's CLI This plumbs the charts marker distance down to vmon's CLI flags in the form of -m/--marker, which you provide the number of pixels distance to put between markers as the argument for. --- src/vmon.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src') diff --git a/src/vmon.c b/src/vmon.c index c9b3d6c..0a63fff 100644 --- a/src/vmon.c +++ b/src/vmon.c @@ -48,6 +48,7 @@ typedef struct vmon_t { time_t start_time; int snapshots_interval; int snapshot; + int marker_distance; int now_names; int headless; int hertz; @@ -189,6 +190,7 @@ static void print_help(void) " -h --help Show this help\n" " -H --height Chart height\n" " -l --linger Don't exit when top-level process exits\n" + " -m --markers Draw markers every N pixels in row borders (0 disables)\n" " -n --name Name of chart, shows in window title and output filenames\n" " -N --now-names Use current time in filenames instead of start time\n" " -o --output-dir Directory to store saved output to (\".\" if unspecified)\n" @@ -419,6 +421,11 @@ static int vmon_handle_argv(vmon_t *vmon, int argc, const char * const *argv) if (!parse_flag_int(argv, end, argv + 1, HEIGHT_MIN, INT_MAX, &vmon->height)) return 0; + last = ++argv; + } else if (is_flag(*argv, "-m", "--markers")) { + if (!parse_flag_int(argv, end, argv + 1, 0, INT_MAX, &vmon->marker_distance)) + return 0; + last = ++argv; } else if (is_flag(*argv, "-o", "--output-dir")) { if (!parse_flag_str(argv, end, argv + 1, 1, &vmon->output_dir)) @@ -622,6 +629,9 @@ static vmon_t * vmon_startup(int argc, const char * const *argv) if (vmon->hertz) vwm_charts_rate_set(vmon->charts, vmon->hertz); + if (vmon->marker_distance) + vwm_charts_marker_distance_set(vmon->charts, vmon->marker_distance); + if (signal(SIGUSR1, handle_sigusr1) == SIG_ERR) { VWM_PERROR("unable to set SIGUSR1 handler"); goto _err_vcr; -- cgit v1.2.3