add ephemeral to line

This commit is contained in:
sawka 2022-08-23 13:14:14 -07:00
parent 429c41cfd0
commit 709920ad8e
4 changed files with 8 additions and 2 deletions

View File

@ -66,6 +66,7 @@ CREATE TABLE line (
linetype varchar(10) NOT NULL,
text text NOT NULL,
cmdid varchar(36) NOT NULL,
ephemeral boolean NOT NULL,
PRIMARY KEY (sessionid, windowid, lineid)
);

View File

@ -386,6 +386,10 @@ func evalCommandInternal(ctx context.Context, pk *scpacket.FeCommandPacketType)
MetaSubCmd: metaSubCmd,
Kwargs: pk.Kwargs,
}
if strings.HasSuffix(commandStr, " ?") {
newPk.Kwargs["ephemeral"] = "1"
commandStr = commandStr[0 : len(commandStr)-2]
}
if metaCmd == "run" || metaCmd == "comment" {
newPk.Args = []string{commandStr}
} else if (metaCmd == "setenv" || metaCmd == "unset") && metaSubCmd == "" {

View File

@ -398,8 +398,8 @@ func InsertLine(ctx context.Context, line *LineType, cmd *CmdType) error {
if !hasWindow {
return fmt.Errorf("window not found, cannot insert line[%s/%s]", line.SessionId, line.WindowId)
}
query = `INSERT INTO line ( sessionid, windowid, lineid, ts, userid, linetype, text, cmdid)
VALUES (:sessionid,:windowid,:lineid,:ts,:userid,:linetype,:text,:cmdid)`
query = `INSERT INTO line ( sessionid, windowid, lineid, ts, userid, linetype, text, cmdid, ephemeral)
VALUES (:sessionid,:windowid,:lineid,:ts,:userid,:linetype,:text,:cmdid,:ephemeral)`
tx.NamedExecWrap(query, line)
if cmd != nil {
cmdMap := cmd.ToMap()

View File

@ -278,6 +278,7 @@ type LineType struct {
LineType string `json:"linetype"`
Text string `json:"text,omitempty"`
CmdId string `json:"cmdid,omitempty"`
Ephemeral bool `json:"ephemeral,omitempty"`
Remove bool `json:"remove,omitempty"`
}