From: Maxime Peim Date: Wed, 13 Aug 2025 15:30:16 +0000 (+0200) Subject: vlib: add possibility to disable pager X-Git-Tag: v26.02-rc0~59 X-Git-Url: https://gerrit.fd.io/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F42%2F43542%2F4;p=vpp.git 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 --- 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) {