From 016b17b99644cbace7fd2485d98fbf9c1682fa52 Mon Sep 17 00:00:00 2001 From: Chapman Pendery Date: Thu, 2 Nov 2023 10:46:29 -0700 Subject: [PATCH] fix: add new exit pathways '^D, exit, logout' Signed-off-by: Chapman Pendery --- src/commands/root.ts | 2 +- src/ui/ui-root.tsx | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/commands/root.ts b/src/commands/root.ts index 0c74385..6e9f6ff 100644 --- a/src/commands/root.ts +++ b/src/commands/root.ts @@ -34,7 +34,7 @@ export const action = async (options: RootCommandOptions) => { while (options.duration === "session" || !executed) { const commandToExecute = await render(startingCommand); - if (commandToExecute == null) { + if (commandToExecute == null || commandToExecute.trim().toLowerCase() == "exit" || commandToExecute.trim().toLowerCase() == "logout") { result = { code: 0 }; break; } diff --git a/src/ui/ui-root.tsx b/src/ui/ui-root.tsx index 94755d0..ab9d4f7 100644 --- a/src/ui/ui-root.tsx +++ b/src/ui/ui-root.tsx @@ -30,7 +30,11 @@ function UI({ startingCommand }: { startingCommand: string }) { } }, []); - useInput((_, key) => { + useInput((input, key) => { + if (key.ctrl && input.toLowerCase() == "d") { + uiResult = undefined; + exit(); + } if (key.return) { setIsExiting(true); }