implement record commands

This commit is contained in:
2025-06-30 12:57:11 +01:00
parent 38e279fe3c
commit f9ec415ea4
3 changed files with 146 additions and 0 deletions

View File

@@ -11,6 +11,9 @@ const commands = {
stream: {
desc: "Manage streaming",
},
record: {
desc: "Manage recording",
},
};
const flags = {

82
utils/record.js Normal file
View File

@@ -0,0 +1,82 @@
import meowHelp from "cli-meow-help";
const commands = {
start: {
desc: "Start streaming",
},
stop: {
desc: "Stop streaming",
},
status: {
desc: "Show the current streaming status",
},
};
const flags = {
help: {
type: "boolean",
shortFlag: "h",
desc: "Display help information",
},
};
const recordHelp = meowHelp({
name: "meld-cli record",
flags,
commands,
description: "Manage recording in Meld",
defaults: false,
});
function recordStart(channel) {
if (!channel.objects || !channel.objects.meld) {
return Promise.reject(new Error("Meld object not found in channel."));
}
const meld = channel.objects.meld;
if (meld.isRecording) {
return Promise.reject(new Error("Recording is already active."));
}
return new Promise((resolve, reject) => {
meld.toggleRecord()
.then(() => {
resolve("Recording started successfully.");
})
.catch((err) => {
reject(err);
});
});
}
function recordStop(channel) {
if (!channel.objects || !channel.objects.meld) {
return Promise.reject(new Error("Meld object not found in channel."));
}
const meld = channel.objects.meld;
if (!meld.isRecording) {
return Promise.reject(new Error("Recording is not currently active."));
}
return new Promise((resolve, reject) => {
meld.toggleRecord()
.then(() => {
resolve("Recording stopped successfully.");
})
.catch((err) => {
reject(err);
});
});
}
function recordStatus(channel) {
if (!channel.objects || !channel.objects.meld) {
return Promise.reject(new Error("Meld object not found in channel."));
}
const meld = channel.objects.meld;
return Promise.resolve(meld.isRecording);
}
export { recordHelp, recordStart, recordStop, recordStatus };