Add draupnir command to switch to safe mode.

Works, but safe mode isn't hooked up to respond to any events.
This commit is contained in:
gnuxie
2024-09-17 18:31:02 +01:00
parent 9959431da8
commit 6b1b44259c
2 changed files with 28 additions and 0 deletions
+2
View File
@@ -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"])
+26
View File
@@ -0,0 +1,26 @@
// SPDX-FileCopyrightText: 2024 Gnuxie <Gnuxie@protonmail.com>
//
// 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<Result<SafeModeDraupnir>> {
return safeModeToggle.switchToSafeMode({
reason: SafeModeReason.ByRequest,
});
},
});
DraupnirInterfaceAdaptor.describeRenderer(DraupnirSafeModeCommand, {
isAlwaysSupposedToUseDefaultRenderer: true,
});