diff --git a/index.js b/index.js index 9de618b..f302721 100755 --- a/index.js +++ b/index.js @@ -33,7 +33,7 @@ socket.onopen = function () { switch (sceneCommand) { case 'list': channel = new QWebChannel(socket, function (channel) { - sceneList(channel) + sceneList(channel, flags.id) .then((scenes) => { console.log(scenes) socket.close() @@ -68,7 +68,7 @@ socket.onopen = function () { break case 'current': channel = new QWebChannel(socket, function (channel) { - sceneCurrent(channel) + sceneCurrent(channel, flags.id) .then((message) => { console.log(message) socket.close() diff --git a/utils/audio.js b/utils/audio.js index 8984061..5ab75a4 100644 --- a/utils/audio.js +++ b/utils/audio.js @@ -29,7 +29,7 @@ const audioHelp = meowHelp({ name: 'meld-cli audio', flags, commands, - description: 'Manage audio settings in Meld', + desc: 'Manage audio settings in Meld', defaults: false }) diff --git a/utils/cli.js b/utils/cli.js index 59a958a..2c62386 100644 --- a/utils/cli.js +++ b/utils/cli.js @@ -43,7 +43,6 @@ const helpText = meowHelp({ name: 'meld-cli', flags, commands, - description: 'A command-line interface for managing scenes in Meld', defaults: false }) diff --git a/utils/record.js b/utils/record.js index 47cf567..8bfc6e8 100644 --- a/utils/record.js +++ b/utils/record.js @@ -24,7 +24,7 @@ const recordHelp = meowHelp({ name: 'meld-cli record', flags, commands, - description: 'Manage recording in Meld', + desc: 'Manage recording in Meld', defaults: false }) diff --git a/utils/scene.js b/utils/scene.js index 0effb07..248a8c7 100644 --- a/utils/scene.js +++ b/utils/scene.js @@ -5,13 +5,13 @@ import { highlight, error, errorHighlight } from './style.js' const commands = { list: { - desc: 'List all scenes' + desc: 'List all scenes, optionally showing IDs' }, switch: { desc: 'Switch to a scene by name' }, current: { - desc: 'Show the current scene' + desc: 'Show the current scene, optionally showing its ID' } } @@ -20,6 +20,10 @@ const flags = { type: 'boolean', shortFlag: 'h', desc: 'Display help information' + }, + id: { + type: 'boolean', + desc: 'Display scene IDs' } } @@ -27,27 +31,35 @@ const sceneHelp = meowHelp({ name: 'meld-cli scene', flags, commands, - description: 'Manage scenes in Meld', + desc: 'Manage scenes in Meld', defaults: false }) -function sceneList (channel) { +function sceneList (channel, showId) { if (!channel.objects || !channel.objects.meld) { return Promise.reject(new Error('Meld object not found in channel.')) } + const headers = [{ content: 'Scene Name', hAlign: 'center' }, { content: 'Active', hAlign: 'center' }] + if (showId) { + headers.push({ content: 'ID', hAlign: 'center' }) + } const table = new Table({ style: { head: ['none'], compact: true }, - head: [{ content: 'Scene Name', hAlign: 'center' }, { content: 'ID', hAlign: 'center' }] + head: headers }) 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)]) + if (showId) { + table.push([highlight(value.name), { content: value.current ? highlight('✓') : '✗', hAlign: 'center' }, highlight(key)]) + } else { + table.push([highlight(value.name), { content: value.current ? highlight('✓') : '✗', hAlign: 'center' }]) + } } } if (table.length === 0) { @@ -82,7 +94,7 @@ function sceneSwitch (channel, sceneName) { }) } -function sceneCurrent (channel) { +function sceneCurrent (channel, showId) { if (!channel.objects || !channel.objects.meld) { return Promise.reject(new Error('Meld object not found in channel.')) } @@ -90,7 +102,10 @@ function sceneCurrent (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(`Current scene: ${highlight(value.name)} (ID: ${highlight(key)})`) + if (showId) { + return Promise.resolve(`Current scene: ${highlight(value.name)} (ID: ${highlight(key)})`) + } + return Promise.resolve(`Current scene: ${highlight(value.name)}`) } } return Promise.reject(new Error('No current scene found.')) diff --git a/utils/stream.js b/utils/stream.js index 30b579f..1dcc0bb 100644 --- a/utils/stream.js +++ b/utils/stream.js @@ -24,7 +24,7 @@ const streamHelp = meowHelp({ name: 'meld-cli stream', flags, commands, - description: 'Manage streaming in Meld', + desc: 'Manage streaming in Meld', defaults: false })