mirror of
https://github.com/onyx-and-iris/meld-cli.git
synced 2026-04-09 02:43:35 +00:00
add some colour
satisfy the linter
This commit is contained in:
262
utils/audio.js
262
utils/audio.js
@@ -1,150 +1,158 @@
|
||||
import meowHelp from "cli-meow-help";
|
||||
import meowHelp from 'cli-meow-help'
|
||||
|
||||
import { highlight, error } from './style.js'
|
||||
|
||||
const commands = {
|
||||
mute: {
|
||||
desc: "Mute the audio",
|
||||
},
|
||||
unmute: {
|
||||
desc: "Unmute the audio",
|
||||
},
|
||||
toggle: {
|
||||
desc: "Toggle audio mute state",
|
||||
},
|
||||
status: {
|
||||
desc: "Show current audio status",
|
||||
},
|
||||
mute: {
|
||||
desc: 'Mute the audio'
|
||||
},
|
||||
unmute: {
|
||||
desc: 'Unmute the audio'
|
||||
},
|
||||
toggle: {
|
||||
desc: 'Toggle audio mute state'
|
||||
},
|
||||
status: {
|
||||
desc: 'Show current audio status'
|
||||
}
|
||||
}
|
||||
|
||||
const flags = {
|
||||
help: {
|
||||
type: "boolean",
|
||||
shortFlag: "h",
|
||||
desc: "Display help information"
|
||||
},
|
||||
};
|
||||
help: {
|
||||
type: 'boolean',
|
||||
shortFlag: 'h',
|
||||
desc: 'Display help information'
|
||||
}
|
||||
}
|
||||
|
||||
const audioHelp = meowHelp({
|
||||
name: "meld-cli audio",
|
||||
flags,
|
||||
commands,
|
||||
description: "Manage audio settings in Meld",
|
||||
defaults: false,
|
||||
});
|
||||
name: 'meld-cli audio',
|
||||
flags,
|
||||
commands,
|
||||
description: 'Manage audio settings in Meld',
|
||||
defaults: false
|
||||
})
|
||||
|
||||
function audioMute(channel, audioName) {
|
||||
if (!channel.objects || !channel.objects.meld) {
|
||||
return Promise.reject(new Error("Meld object not found in channel."));
|
||||
}
|
||||
const meld = channel.objects.meld;
|
||||
let itemId;
|
||||
let isMuted;
|
||||
for (const [key, value] of Object.entries(meld.session.items)) {
|
||||
if (value.type === "track" && value.name === audioName) {
|
||||
itemId = key;
|
||||
isMuted = value.muted;
|
||||
break;
|
||||
}
|
||||
function audioMute (channel, audioName) {
|
||||
if (!channel.objects || !channel.objects.meld) {
|
||||
return Promise.reject(new Error(error('Meld object not found in channel.')))
|
||||
}
|
||||
const meld = channel.objects.meld
|
||||
let itemId
|
||||
let isMuted
|
||||
for (const [key, value] of Object.entries(meld.session.items)) {
|
||||
if (value.type === 'track' && value.name === audioName) {
|
||||
itemId = key
|
||||
isMuted = value.muted
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (!itemId) {
|
||||
return Promise.reject(new Error(`No audio device with name ${audioName} found.`));
|
||||
}
|
||||
if (isMuted) {
|
||||
return Promise.resolve(`Audio track ${audioName} is already muted.`);
|
||||
}
|
||||
if (!itemId) {
|
||||
return Promise.reject(new Error(`No audio device with name ${audioName} found.`))
|
||||
}
|
||||
if (isMuted) {
|
||||
return Promise.resolve(`Audio track ${highlight(audioName)} is already muted.`)
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
meld.toggleMute(itemId)
|
||||
.then(() => {
|
||||
resolve(`Audio track ${audioName} has been muted.`);
|
||||
})
|
||||
.catch((err) => {
|
||||
reject(new Error(`Error muting audio track: ${err}`));
|
||||
});
|
||||
})
|
||||
return new Promise((resolve, reject) => {
|
||||
meld.toggleMute(itemId)
|
||||
.then(() => {
|
||||
resolve(`Audio track ${highlight(audioName)} has been muted.`)
|
||||
})
|
||||
.catch((err) => {
|
||||
reject(new Error(`Error muting audio track: ${err}`))
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function audioUnmute(channel, audioName) {
|
||||
if (!channel.objects || !channel.objects.meld) {
|
||||
return Promise.reject(new Error("Meld object not found in channel."));
|
||||
}
|
||||
const meld = channel.objects.meld;
|
||||
let itemId;
|
||||
let isMuted;
|
||||
for (const [key, value] of Object.entries(meld.session.items)) {
|
||||
if (value.type === "track" && value.name === audioName) {
|
||||
itemId = key;
|
||||
isMuted = value.muted;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!itemId) {
|
||||
return Promise.reject(new Error("No audio track found."));
|
||||
}
|
||||
if (!isMuted) {
|
||||
return Promise.resolve(`Audio track ${audioName} is already unmuted.`);
|
||||
function audioUnmute (channel, audioName) {
|
||||
if (!channel.objects || !channel.objects.meld) {
|
||||
return Promise.reject(new Error('Meld object not found in channel.'))
|
||||
}
|
||||
const meld = channel.objects.meld
|
||||
let itemId
|
||||
let isMuted
|
||||
for (const [key, value] of Object.entries(meld.session.items)) {
|
||||
if (value.type === 'track' && value.name === audioName) {
|
||||
itemId = key
|
||||
isMuted = value.muted
|
||||
break
|
||||
}
|
||||
}
|
||||
if (!itemId) {
|
||||
return Promise.reject(new Error('No audio track found.'))
|
||||
}
|
||||
if (!isMuted) {
|
||||
return Promise.resolve(`Audio track ${audioName} is already unmuted.`)
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
meld.toggleMute(itemId)
|
||||
.then(() => {
|
||||
resolve(`Audio track ${audioName} has been unmuted.`);
|
||||
})
|
||||
.catch((err) => {
|
||||
reject(new Error(`Error unmuting audio track: ${err}`));
|
||||
});
|
||||
});
|
||||
return new Promise((resolve, reject) => {
|
||||
meld.toggleMute(itemId)
|
||||
.then(() => {
|
||||
resolve(`Audio track ${audioName} has been unmuted.`)
|
||||
})
|
||||
.catch((err) => {
|
||||
reject(new Error(`Error unmuting audio track: ${err}`))
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function audioToggle(channel, audioName) {
|
||||
if (!channel.objects || !channel.objects.meld) {
|
||||
return Promise.reject(new Error("Meld object not found in channel."));
|
||||
function audioToggle (channel, audioName) {
|
||||
if (!channel.objects || !channel.objects.meld) {
|
||||
return Promise.reject(new Error('Meld object not found in channel.'))
|
||||
}
|
||||
const meld = channel.objects.meld
|
||||
let itemId
|
||||
let isMuted
|
||||
for (const [key, value] of Object.entries(meld.session.items)) {
|
||||
if (value.type === 'track' && value.name === audioName) {
|
||||
itemId = key
|
||||
isMuted = value.muted
|
||||
break
|
||||
}
|
||||
const meld = channel.objects.meld;
|
||||
let itemId;
|
||||
let isMuted;
|
||||
for (const [key, value] of Object.entries(meld.session.items)) {
|
||||
if (value.type === "track" && value.name === audioName) {
|
||||
itemId = key;
|
||||
isMuted = value.muted;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!itemId) {
|
||||
return Promise.reject(new Error(`No audio device with name ${audioName} found.`));
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
meld.toggleMute(itemId)
|
||||
.then(() => {
|
||||
const status = isMuted ? "unmuted" : "muted";
|
||||
resolve(`Audio track ${audioName} has been ${status}.`);
|
||||
})
|
||||
.catch((err) => {
|
||||
reject(new Error(`Error toggling audio track: ${err}`));
|
||||
});
|
||||
});
|
||||
}
|
||||
if (!itemId) {
|
||||
return Promise.reject(new Error(`No audio device with name ${audioName} found.`))
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
meld.toggleMute(itemId)
|
||||
.then(() => {
|
||||
const status = isMuted ? 'unmuted' : 'muted'
|
||||
resolve(`Audio track ${audioName} has been ${status}.`)
|
||||
})
|
||||
.catch((err) => {
|
||||
reject(new Error(`Error toggling audio track: ${err}`))
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function audioStatus(channel, audioName) {
|
||||
if (!channel.objects || !channel.objects.meld) {
|
||||
return Promise.reject(new Error("Meld object not found in channel."));
|
||||
function audioStatus (channel, audioName) {
|
||||
if (!channel.objects || !channel.objects.meld) {
|
||||
return Promise.reject(new Error('Meld object not found in channel.'))
|
||||
}
|
||||
const meld = channel.objects.meld
|
||||
let itemId
|
||||
let isMuted
|
||||
for (const [key, value] of Object.entries(meld.session.items)) {
|
||||
if (value.type === 'track' && value.name === audioName) {
|
||||
itemId = key
|
||||
isMuted = value.muted
|
||||
break
|
||||
}
|
||||
const meld = channel.objects.meld;
|
||||
let itemId;
|
||||
let isMuted;
|
||||
for (const [key, value] of Object.entries(meld.session.items)) {
|
||||
if (value.type === "track" && value.name === audioName) {
|
||||
itemId = key;
|
||||
isMuted = value.muted;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!itemId) {
|
||||
return Promise.reject(new Error(`No audio device with name ${audioName} found.`));
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(isMuted);
|
||||
});
|
||||
}
|
||||
if (!itemId) {
|
||||
return Promise.reject(new Error(`No audio device with name ${audioName} found.`))
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(`${highlight(audioName)} is ${isMuted ? 'muted' : 'unmuted'}`)
|
||||
})
|
||||
}
|
||||
|
||||
export { audioHelp, audioMute, audioUnmute, audioToggle, audioStatus }
|
||||
export {
|
||||
audioHelp,
|
||||
audioMute,
|
||||
audioUnmute,
|
||||
audioToggle,
|
||||
audioStatus
|
||||
}
|
||||
|
||||
68
utils/cli.js
68
utils/cli.js
@@ -1,43 +1,43 @@
|
||||
import meow from "meow";
|
||||
import meowHelp from "cli-meow-help";
|
||||
import meow from 'meow'
|
||||
import meowHelp from 'cli-meow-help'
|
||||
|
||||
const commands = {
|
||||
scene: {
|
||||
desc: "Manage scenes",
|
||||
},
|
||||
audio: {
|
||||
desc: "Manage audio settings",
|
||||
},
|
||||
stream: {
|
||||
desc: "Manage streaming",
|
||||
},
|
||||
record: {
|
||||
desc: "Manage recording",
|
||||
},
|
||||
};
|
||||
scene: {
|
||||
desc: 'Manage scenes'
|
||||
},
|
||||
audio: {
|
||||
desc: 'Manage audio settings'
|
||||
},
|
||||
stream: {
|
||||
desc: 'Manage streaming'
|
||||
},
|
||||
record: {
|
||||
desc: 'Manage recording'
|
||||
}
|
||||
}
|
||||
|
||||
const flags = {
|
||||
help: {
|
||||
type: "boolean",
|
||||
shortFlag: "h",
|
||||
description: "Display help information"
|
||||
},
|
||||
version: {
|
||||
type: "boolean",
|
||||
shortFlag: "v",
|
||||
description: "Display the version number"
|
||||
}
|
||||
help: {
|
||||
type: 'boolean',
|
||||
shortFlag: 'h',
|
||||
description: 'Display help information'
|
||||
},
|
||||
version: {
|
||||
type: 'boolean',
|
||||
shortFlag: 'v',
|
||||
description: 'Display the version number'
|
||||
}
|
||||
}
|
||||
|
||||
const helpText = meowHelp({
|
||||
name: "meld-cli",
|
||||
flags,
|
||||
commands,
|
||||
description: "A command-line interface for managing scenes in Meld",
|
||||
defaults: false,
|
||||
});
|
||||
name: 'meld-cli',
|
||||
flags,
|
||||
commands,
|
||||
description: 'A command-line interface for managing scenes in Meld',
|
||||
defaults: false
|
||||
})
|
||||
|
||||
export default meow(helpText, {
|
||||
importMeta: import.meta,
|
||||
flags,
|
||||
})
|
||||
importMeta: import.meta,
|
||||
flags
|
||||
})
|
||||
|
||||
133
utils/record.js
133
utils/record.js
@@ -1,82 +1,87 @@
|
||||
import meowHelp from "cli-meow-help";
|
||||
import meowHelp from 'cli-meow-help'
|
||||
|
||||
const commands = {
|
||||
start: {
|
||||
desc: "Start streaming",
|
||||
},
|
||||
stop: {
|
||||
desc: "Stop streaming",
|
||||
},
|
||||
status: {
|
||||
desc: "Show the current streaming status",
|
||||
},
|
||||
};
|
||||
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",
|
||||
},
|
||||
};
|
||||
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,
|
||||
});
|
||||
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."));
|
||||
}
|
||||
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."));
|
||||
}
|
||||
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);
|
||||
});
|
||||
});
|
||||
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."));
|
||||
}
|
||||
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."));
|
||||
}
|
||||
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);
|
||||
});
|
||||
});
|
||||
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."));
|
||||
}
|
||||
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);
|
||||
const meld = channel.objects.meld
|
||||
return Promise.resolve(`Recording is currently ${meld.isRecording ? 'active' : 'inactive'}`)
|
||||
}
|
||||
|
||||
export { recordHelp, recordStart, recordStop, recordStatus };
|
||||
export {
|
||||
recordHelp,
|
||||
recordStart,
|
||||
recordStop,
|
||||
recordStatus
|
||||
}
|
||||
|
||||
154
utils/scene.js
154
utils/scene.js
@@ -1,90 +1,104 @@
|
||||
import meowHelp from "cli-meow-help";
|
||||
import meowHelp from 'cli-meow-help'
|
||||
import Table from 'cli-table3'
|
||||
|
||||
import { highlight, error, errorHighlight } from './style.js'
|
||||
|
||||
const commands = {
|
||||
list: {
|
||||
desc: "List all scenes",
|
||||
},
|
||||
switch: {
|
||||
desc: "Switch to a scene by name",
|
||||
},
|
||||
current: {
|
||||
desc: "Show the current scene",
|
||||
},
|
||||
list: {
|
||||
desc: 'List all scenes'
|
||||
},
|
||||
switch: {
|
||||
desc: 'Switch to a scene by name'
|
||||
},
|
||||
current: {
|
||||
desc: 'Show the current scene'
|
||||
}
|
||||
}
|
||||
|
||||
const flags = {
|
||||
help: {
|
||||
type: "boolean",
|
||||
shortFlag: "h",
|
||||
desc: "Display help information"
|
||||
},
|
||||
};
|
||||
help: {
|
||||
type: 'boolean',
|
||||
shortFlag: 'h',
|
||||
desc: 'Display help information'
|
||||
}
|
||||
}
|
||||
|
||||
const sceneHelp = meowHelp({
|
||||
name: "meld-cli scene",
|
||||
flags,
|
||||
commands,
|
||||
description: "Manage scenes in Meld",
|
||||
defaults: false,
|
||||
});
|
||||
name: 'meld-cli scene',
|
||||
flags,
|
||||
commands,
|
||||
description: 'Manage scenes in Meld',
|
||||
defaults: false
|
||||
})
|
||||
|
||||
function sceneList(channel) {
|
||||
if (!channel.objects || !channel.objects.meld) {
|
||||
return Promise.reject(new Error("Meld object not found in channel."));
|
||||
function sceneList (channel) {
|
||||
if (!channel.objects || !channel.objects.meld) {
|
||||
return Promise.reject(new Error('Meld object not found in channel.'))
|
||||
}
|
||||
|
||||
const table = new Table({
|
||||
style: {
|
||||
head: ['none'],
|
||||
compact: true
|
||||
},
|
||||
head: [{ content: 'Scene Name', hAlign: 'center' }, { content: 'ID', hAlign: 'center' }]
|
||||
})
|
||||
|
||||
const meld = channel.objects.meld
|
||||
for (const [key, value] of Object.entries(meld.session.items)) {
|
||||
if (value.type === 'scene') {
|
||||
table.push([highlight(value.name), highlight(key)])
|
||||
}
|
||||
|
||||
const meld = channel.objects.meld;
|
||||
const scenes = [];
|
||||
for (const [key, value] of Object.entries(meld.session.items)) {
|
||||
if (value.type === "scene") {
|
||||
scenes.push({ name: value.name, id: key });
|
||||
}
|
||||
}
|
||||
if (scenes.length === 0) {
|
||||
return Promise.reject(new Error("No scenes found."));
|
||||
}
|
||||
return Promise.resolve(scenes);
|
||||
}
|
||||
if (table.length === 0) {
|
||||
return Promise.reject(new Error('No scenes found.'))
|
||||
}
|
||||
return Promise.resolve(table.toString())
|
||||
}
|
||||
|
||||
function sceneSwitch(channel, sceneName) {
|
||||
if (!channel.objects || !channel.objects.meld) {
|
||||
return Promise.reject(new Error("Meld object not found in channel."));
|
||||
}
|
||||
function sceneSwitch (channel, sceneName) {
|
||||
if (!channel.objects || !channel.objects.meld) {
|
||||
return Promise.reject(new Error('Meld object not found in channel.'))
|
||||
}
|
||||
|
||||
const meld = channel.objects.meld;
|
||||
let itemId;
|
||||
for (const [key, value] of Object.entries(meld.session.items)) {
|
||||
if (value.type === "scene" && value.name === sceneName) {
|
||||
itemId = key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!itemId) {
|
||||
return Promise.reject(new Error(`Scene "${sceneName}" not found.`));
|
||||
const meld = channel.objects.meld
|
||||
let itemId
|
||||
for (const [key, value] of Object.entries(meld.session.items)) {
|
||||
if (value.type === 'scene' && value.name === sceneName) {
|
||||
itemId = key
|
||||
break
|
||||
}
|
||||
}
|
||||
if (!itemId) {
|
||||
return Promise.reject(new Error(error(`No scene with name ${errorHighlight(sceneName)} found.`)))
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
meld.showScene(itemId).then(() => {
|
||||
console.log(`Switched to scene: ${sceneName}`);
|
||||
resolve();
|
||||
}).catch(err => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
return new Promise((resolve, reject) => {
|
||||
meld.showScene(itemId).then(() => {
|
||||
resolve(`Switched to scene: ${highlight(sceneName)}`)
|
||||
}).catch(err => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function sceneCurrent(channel) {
|
||||
if (!channel.objects || !channel.objects.meld) {
|
||||
return Promise.reject(new Error("Meld object not found in channel."));
|
||||
}
|
||||
function sceneCurrent (channel) {
|
||||
if (!channel.objects || !channel.objects.meld) {
|
||||
return Promise.reject(new Error('Meld object not found in channel.'))
|
||||
}
|
||||
|
||||
const meld = channel.objects.meld;
|
||||
for (const [key, value] of Object.entries(meld.session.items)) {
|
||||
if (value.type === "scene" && value.current) {
|
||||
return Promise.resolve({ name: value.name, id: key });
|
||||
}
|
||||
const meld = channel.objects.meld
|
||||
for (const [key, value] of Object.entries(meld.session.items)) {
|
||||
if (value.type === 'scene' && value.current) {
|
||||
return Promise.resolve(`Current scene: ${highlight(value.name)} (ID: ${highlight(key)})`)
|
||||
}
|
||||
return Promise.reject(new Error("No current scene found."));
|
||||
}
|
||||
return Promise.reject(new Error('No current scene found.'))
|
||||
}
|
||||
|
||||
export { sceneHelp, sceneList, sceneSwitch, sceneCurrent };
|
||||
export {
|
||||
sceneHelp,
|
||||
sceneList,
|
||||
sceneSwitch,
|
||||
sceneCurrent
|
||||
}
|
||||
|
||||
134
utils/stream.js
134
utils/stream.js
@@ -1,83 +1,87 @@
|
||||
import meowHelp from "cli-meow-help";
|
||||
import meowHelp from 'cli-meow-help'
|
||||
|
||||
const commands = {
|
||||
start: {
|
||||
desc: "Start streaming",
|
||||
},
|
||||
stop: {
|
||||
desc: "Stop streaming",
|
||||
},
|
||||
status: {
|
||||
desc: "Show the current streaming status",
|
||||
},
|
||||
};
|
||||
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",
|
||||
},
|
||||
};
|
||||
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,
|
||||
});
|
||||
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."));
|
||||
}
|
||||
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."));
|
||||
}
|
||||
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);
|
||||
});
|
||||
});
|
||||
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."));
|
||||
}
|
||||
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."));
|
||||
}
|
||||
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);
|
||||
});
|
||||
});
|
||||
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.'))
|
||||
}
|
||||
|
||||
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);
|
||||
const meld = channel.objects.meld
|
||||
return Promise.resolve(`Streaming is currently ${meld.isStreaming ? 'active' : 'inactive'}`)
|
||||
}
|
||||
|
||||
export { streamHelp, streamStart, streamStop, streamStatus };
|
||||
export {
|
||||
streamStart,
|
||||
streamStop,
|
||||
streamStatus,
|
||||
streamHelp
|
||||
}
|
||||
|
||||
11
utils/style.js
Normal file
11
utils/style.js
Normal file
@@ -0,0 +1,11 @@
|
||||
import clc from 'cli-color'
|
||||
|
||||
const highlight = clc.cyan
|
||||
const error = clc.red.bold
|
||||
const errorHighlight = clc.yellow.bold
|
||||
|
||||
export {
|
||||
highlight,
|
||||
error,
|
||||
errorHighlight
|
||||
}
|
||||
Reference in New Issue
Block a user