From 72b90883f9913a29581589cb5954e0f02ca63778 Mon Sep 17 00:00:00 2001 From: Vadim Yanitskiy Date: Wed, 21 Oct 2020 05:07:34 +0700 Subject: vty: introduce the expert mode and a command to enable it Some VTY commands are intentionally hidden, e.g. because they might by relatively dangerous if used in production operation. We equip such commands with a special attribute - CMD_ATTR_HIDDEN. The problem is that neiter they appear in the XML VTY reference, nor in the online VTY help, so it's a bit tricky to invoke them. This change introduces so-called 'expert' mode, in which hidden (but not deprecated) commands are getting visible. In the (telnet) VTY session, this mode can be activated by passing an additional argument to well-known 'enable' command: OsmoApp> enable ? [expert-mode] Enable the expert mode (show hidden commands) OsmoApp> enable expert-mode OsmoApp# so then hidden commands will appear together with all the other commands. They will be marked with a special '^' flag: OsmoApp# list with-flags ^ ... foo-hidden [expert-mode] . ... foo-regular-one ! ... foo-immediate ^ u.. app-hidden-unbelievable For the XML reference generation, additional API needs to be introduced. This will be implemented in subsequent patches. Change-Id: Ie69c2a19b22fb31d7bd7f6412f0aeac86ea5048f Related: SYS#4910 --- include/osmocom/vty/command.h | 4 ++++ include/osmocom/vty/vty.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'include/osmocom/vty') diff --git a/include/osmocom/vty/command.h b/include/osmocom/vty/command.h index 2cb45dd3..92701fcb 100644 --- a/include/osmocom/vty/command.h +++ b/include/osmocom/vty/command.h @@ -24,6 +24,7 @@ #pragma once #include +#include #include #include "vector.h" @@ -65,6 +66,9 @@ struct host { /*! VTY application information */ const struct vty_app_info *app_info; + + /*! Whether the expert mode is enabled. */ + bool expert_mode; }; /*! There are some command levels which called from command node. */ diff --git a/include/osmocom/vty/vty.h b/include/osmocom/vty/vty.h index 4e83b1bb..6a82d7e3 100644 --- a/include/osmocom/vty/vty.h +++ b/include/osmocom/vty/vty.h @@ -32,7 +32,7 @@ #define VTY_CMD_USR_ATTR_NUM 32 /* Flag characters reserved for global VTY attributes */ #define VTY_CMD_ATTR_FLAGS_RESERVED \ - { '.', '!', '@' } + { '.', '!', '@', '^' } /*! VTY events */ enum event { -- cgit v1.2.3