diff --git a/src/commands/DraupnirCommands.ts b/src/commands/DraupnirCommands.ts index 9ff0f252..997177c5 100644 --- a/src/commands/DraupnirCommands.ts +++ b/src/commands/DraupnirCommands.ts @@ -47,6 +47,7 @@ import { DraupnirWatchPolicyRoomCommand, } from "./WatchUnwatchCommand"; import { DraupnirTopLevelCommands } from "./DraupnirCommandTable"; +import { DraupnirSafeModeCommand } from "./SafeModeCommand"; // TODO: These commands should all be moved to subdirectories tbh and this // should be split like an index file for each subdirectory. @@ -88,6 +89,7 @@ const DraupnirCommands = new StandardCommandTable("draupnir") .internCommand(DraupnirRoomsRemoveCommand, ["rooms", "remove"]) .internCommand(DraupnirListRulesCommand, ["rules"]) .internCommand(DraupnirRulesMatchingCommand, ["rules", "matching"]) + .internCommand(DraupnirSafeModeCommand, ["safe", "mode"]) .internCommand(DraupnirDisplaynameCommand, ["displayname"]) .internCommand(DraupnirSetPowerLevelCommand, ["powerlevel"]) .internCommand(DraupnirStatusCommand, ["status"]) diff --git a/src/commands/SafeModeCommand.ts b/src/commands/SafeModeCommand.ts new file mode 100644 index 00000000..96cf62fc --- /dev/null +++ b/src/commands/SafeModeCommand.ts @@ -0,0 +1,26 @@ +// SPDX-FileCopyrightText: 2024 Gnuxie +// +// SPDX-License-Identifier: AFL-3.0 + +import { describeCommand } from "@the-draupnir-project/interface-manager"; +import { SafeModeDraupnir } from "../safemode/DraupnirSafeMode"; +import { Result } from "@gnuxie/typescript-result"; +import { Draupnir } from "../Draupnir"; +import { SafeModeReason } from "../safemode/SafeModeCause"; +import { DraupnirInterfaceAdaptor } from "./DraupnirCommandPrerequisites"; + +export const DraupnirSafeModeCommand = describeCommand({ + summary: "Enter into safe mode.", + parameters: [], + async executor({ + safeModeToggle, + }: Draupnir): Promise> { + return safeModeToggle.switchToSafeMode({ + reason: SafeModeReason.ByRequest, + }); + }, +}); + +DraupnirInterfaceAdaptor.describeRenderer(DraupnirSafeModeCommand, { + isAlwaysSupposedToUseDefaultRenderer: true, +});