mirror of
https://github.com/eclipse-mosquitto/mosquitto.git
synced 2026-08-17 17:41:58 +08:00
Ctrl shell: Add colours for printing topics and +ve and -ve responses
Apply to the getRole command
This commit is contained in:
@@ -51,6 +51,9 @@ const char *ANSI_INPUT = NULL;
|
||||
const char *ANSI_ERROR = NULL;
|
||||
const char **ANSI_LABEL = NULL;
|
||||
const char *ANSI_RESET = "\001\e[0m\002";
|
||||
const char *ANSI_TOPIC = NULL;
|
||||
const char *ANSI_POSITIVE = NULL;
|
||||
const char *ANSI_NEGATIVE = NULL;
|
||||
|
||||
const char *ANSI_LABEL_none[] = {"", ""};
|
||||
|
||||
@@ -62,6 +65,9 @@ const char *ANSI_LABEL_dark[] = {
|
||||
"\001\e[38;5;207m\002",
|
||||
"\001\e[38;5;219m\002",
|
||||
};
|
||||
const char ANSI_TOPIC_dark[] = "\001\e[93m\002";
|
||||
const char ANSI_POSITIVE_dark[] = "\001\e[92m\002";
|
||||
const char ANSI_NEGATIVE_dark[] = "\001\e[95m\002";
|
||||
|
||||
const char ANSI_URL_light[] = "\001\e[38;5;23m\002";
|
||||
const char ANSI_MODULE_light[] = "\001\e[38;5;130m\002";
|
||||
@@ -71,6 +77,9 @@ const char *ANSI_LABEL_light[] = {
|
||||
"\001\e[38;5;165m\002",
|
||||
"\001\e[38;5;171m\002",
|
||||
};
|
||||
const char ANSI_TOPIC_light[] = "\001\e[33m\002";
|
||||
const char ANSI_POSITIVE_light[] = "\001\e[32m\002";
|
||||
const char ANSI_NEGATIVE_light[] = "\001\e[35m\002";
|
||||
|
||||
|
||||
char prompt[200];
|
||||
@@ -589,6 +598,9 @@ void set_no_colour(void)
|
||||
ANSI_ERROR = "";
|
||||
ANSI_LABEL = ANSI_LABEL_none;
|
||||
ANSI_RESET = "";
|
||||
ANSI_TOPIC = "";
|
||||
ANSI_POSITIVE = "";
|
||||
ANSI_NEGATIVE = "";
|
||||
}
|
||||
|
||||
static void set_bg_light(void)
|
||||
@@ -598,6 +610,9 @@ static void set_bg_light(void)
|
||||
ANSI_INPUT = ANSI_INPUT_light;
|
||||
ANSI_ERROR = ANSI_ERROR_light;
|
||||
ANSI_LABEL = ANSI_LABEL_light;
|
||||
ANSI_TOPIC = ANSI_TOPIC_light;
|
||||
ANSI_POSITIVE = ANSI_POSITIVE_light;
|
||||
ANSI_NEGATIVE = ANSI_NEGATIVE_light;
|
||||
}
|
||||
|
||||
static void set_bg_dark(void)
|
||||
@@ -607,6 +622,9 @@ static void set_bg_dark(void)
|
||||
ANSI_INPUT = ANSI_INPUT_dark;
|
||||
ANSI_ERROR = ANSI_ERROR_dark;
|
||||
ANSI_LABEL = ANSI_LABEL_dark;
|
||||
ANSI_TOPIC = ANSI_TOPIC_dark;
|
||||
ANSI_POSITIVE = ANSI_POSITIVE_dark;
|
||||
ANSI_NEGATIVE = ANSI_NEGATIVE_dark;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -31,6 +31,9 @@ extern const char *ANSI_INPUT;
|
||||
extern const char *ANSI_ERROR;
|
||||
extern const char **ANSI_LABEL;
|
||||
extern const char *ANSI_RESET;
|
||||
extern const char *ANSI_TOPIC;
|
||||
extern const char *ANSI_POSITIVE;
|
||||
extern const char *ANSI_NEGATIVE;
|
||||
|
||||
/* This relatively complex structure is used to store the command tree. It
|
||||
* allows for commands to be shared between different parts of the tree, and
|
||||
|
||||
@@ -915,7 +915,8 @@ static void print_role(cJSON *j_data)
|
||||
&& json_get_bool(j_acl, "allow", &allow, false, false) == MOSQ_ERR_SUCCESS
|
||||
){
|
||||
|
||||
ctrl_shell_print_value(1, "%-*s %s %s (priority %d)\n", (int)strlen("publishClientReceive"), acltype, allow?"allow":"deny ", topic, priority);
|
||||
const char *ANSI_ALLOW = allow?ANSI_POSITIVE:ANSI_NEGATIVE;
|
||||
ctrl_shell_print_value(1, "%-*s %s%s%s %s%s%s (priority %d)\n", (int)strlen("publishClientReceive"), acltype, ANSI_ALLOW, allow?"allow":"deny", ANSI_RESET, ANSI_TOPIC, topic, ANSI_RESET, priority);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user