MEDIUM: cli: write a prompt for the CLI proxy of the master
Write a prompt with the PID of the target or master.
It's always activated for now.
Example:
1234>
master>
diff --git a/src/cli.c b/src/cli.c
index 6e7c3d0..5e8df25 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -1620,6 +1620,18 @@
return 1;
}
+void pcli_write_prompt(struct stream *s)
+{
+ struct buffer *msg = get_trash_chunk();
+ struct channel *oc = si_oc(&s->si[0]);
+
+ if (s->pcli_next_pid == 0)
+ chunk_appendf(msg, "master> ");
+ else
+ chunk_appendf(msg, "%d> ", s->pcli_next_pid);
+ co_inject(oc, msg->area, msg->data);
+}
+
/* The pcli_* functions are used for the CLI proxy in the master */
@@ -1880,7 +1892,7 @@
command for this session */
if (target_pid > -1) {
s->pcli_next_pid = target_pid;
- // TODO: pcli_reply the prompt
+ pcli_write_prompt(s);
} else {
// TODO: pcli_reply() error
s->pcli_next_pid = 0;
@@ -1922,6 +1934,8 @@
if ((rep->flags & (CF_SHUTR|CF_READ_NULL))) {
/* stream cleanup */
+ pcli_write_prompt(s);
+
s->si[1].flags |= SI_FL_NOLINGER | SI_FL_NOHALF;
si_shutr(&s->si[1]);
si_shutw(&s->si[1]);