vlib: add possibility to disable pager 42/43542/4
authorMaxime Peim <[email protected]>
Wed, 13 Aug 2025 15:30:16 +0000 (17:30 +0200)
committerDamjan Marion <[email protected]>
Thu, 28 Aug 2025 19:12:40 +0000 (19:12 +0000)
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 <[email protected]>
src/vlib/unix/cli.c
src/vlib/unix/unix.h

index 8f0f00c..e835a52 100644 (file)
@@ -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.
index d0b7a4c..e3aad36 100644 (file)
@@ -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)
 {