Skip to content

Commit

Permalink
Added ability to send json string in cli
Browse files Browse the repository at this point in the history
  • Loading branch information
wondertwins committed Dec 10, 2023
1 parent 3eaf196 commit a18baeb
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 3 deletions.
Binary file added .DS_Store
Binary file not shown.
Binary file added cli/.DS_Store
Binary file not shown.
Binary file added cli/commands/.DS_Store
Binary file not shown.
Binary file added cli/commands/app/.DS_Store
Binary file not shown.
17 changes: 14 additions & 3 deletions cli/commands/app/launch.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as log from '../../log.js';
import chalk from 'chalk';
import WebosTvHelper from '../../../lib/tools/WebosTvHelper.js';

export const command = 'launch <ip> <mac> <appId>';
export const command = 'launch <ip> <mac> <appId> [appParams]';
export const description = 'Launch the app with the specified appId on the TV';
export const builder = {
timeout: {
Expand All @@ -16,6 +16,11 @@ export const builder = {
alias: 'd',
type: 'boolean',
description: 'Enable debug output'
},
appParams: {
required: false,
type: 'string',
description: 'JSON string of parameters to pass to the app'
}
};

Expand All @@ -25,17 +30,23 @@ export const handler = async argv => {
mac,
appId,
timeout,
debug
debug,
appParams
} = argv;

try {
log.info(`Trying to launch the app with appId: ${chalk.green.bold(appId)} on the TV (${chalk.yellow(ip)})`);
let lgTvCtrl = await WebosTvHelper.connect(ip, mac, debug, timeout);
await lgTvCtrl.launchApp(appId, {});

// Parse appParams if provided, otherwise use empty object
let params = appParams ? JSON.parse(appParams) : {};

await lgTvCtrl.launchApp(appId, params);
log.success(`Launched app with appId: ${chalk.green.bold(appId)}`);
} catch (err) {
log.error(err.message);
}

process.exit(0);
};

0 comments on commit a18baeb

Please sign in to comment.