mirror of
https://github.com/onyx-and-iris/meld-cli.git
synced 2026-04-09 02:43:35 +00:00
implement stream commands
This commit is contained in:
@@ -8,6 +8,9 @@ const commands = {
|
||||
audio: {
|
||||
desc: "Manage audio settings",
|
||||
},
|
||||
stream: {
|
||||
desc: "Manage streaming",
|
||||
},
|
||||
};
|
||||
|
||||
const flags = {
|
||||
|
||||
83
utils/stream.js
Normal file
83
utils/stream.js
Normal file
@@ -0,0 +1,83 @@
|
||||
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 streamHelp = meowHelp({
|
||||
name: "meld-cli stream",
|
||||
flags,
|
||||
commands,
|
||||
description: "Manage streaming in Meld",
|
||||
defaults: false,
|
||||
});
|
||||
|
||||
function streamStart(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.isStreaming) {
|
||||
return Promise.reject(new Error("Streaming is already active."));
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
meld.toggleStream()
|
||||
.then(() => {
|
||||
resolve("Streaming started successfully.");
|
||||
})
|
||||
.catch((err) => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function streamStop(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.isStreaming) {
|
||||
return Promise.reject(new Error("Streaming is not currently active."));
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
meld.toggleStream()
|
||||
.then(() => {
|
||||
resolve("Streaming stopped successfully.");
|
||||
})
|
||||
.catch((err) => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function streamStatus(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.isStreaming);
|
||||
}
|
||||
|
||||
export { streamHelp, streamStart, streamStop, streamStatus };
|
||||
Reference in New Issue
Block a user