From d23c6284f9fae3d216046a891eae6d76c515114a Mon Sep 17 00:00:00 2001 From: Maxime Peim Date: Wed, 13 Aug 2025 17:30:16 +0200 Subject: [PATCH] vlib: add possibility to disable pager For the current running cli process, it can be useful to be able to disable the pager in case of long running command (e.g. ping). For a small window, the pager will prompt and hide the results of the command. Type: improvement Change-Id: I8fdde7f581683a8d9fd702a744fb95b5c58e14ff Signed-off-by: Maxime Peim --- src/vlib/unix/cli.c | 15 +++++++++++++++ src/vlib/unix/unix.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/src/vlib/unix/cli.c b/src/vlib/unix/cli.c index 8f0f00c8b9f..e835a5295d3 100644 --- a/src/vlib/unix/cli.c +++ b/src/vlib/unix/cli.c @@ -3287,6 +3287,21 @@ unix_cli_file_if_interactive (unix_cli_main_t * cm) return cf; } +u8 +vlib_unix_cli_enable_disable_pager (u8 enable) +{ + unix_cli_main_t *cm = &unix_cli_main; + unix_cli_file_t *cf = unix_cli_file_if_interactive (cm); + u8 old; + + if (!cf) + return ~0; + + old = !cf->no_pager; + cf->no_pager = !enable; + return old; +} + /** CLI command to quit the terminal session. * @note If this is a stdin session then this will * shutdown VPP also. diff --git a/src/vlib/unix/unix.h b/src/vlib/unix/unix.h index d0b7a4c7005..e3aad366f3c 100644 --- a/src/vlib/unix/unix.h +++ b/src/vlib/unix/unix.h @@ -140,6 +140,8 @@ int vlib_unix_main (int argc, char *argv[]); /* Set prompt for CLI. */ void vlib_unix_cli_set_prompt (char *prompt); +u8 vlib_unix_cli_enable_disable_pager (u8 enable); + static inline unix_main_t * vlib_unix_get_main (void) { -- 2.16.6