Files
ChannelTests-TS/test/config/example-usage.ts
Alexander Zinn 4b672f231f Add command line parsing and configuration management
* Introduced `CommandLine` class for handling command line options and arguments
* Added `TestConfiguration` class to manage application credentials and URIs
* Implemented example usage for generating command line arguments from a configuration object
* Updated `package.json` to include `commander` dependency
* Removed unused `TestRunner` class and created a new `TestRunner` for executing tests with command line options
* Adjusted logging level type to use lowercase values for consistency
2025-08-18 17:54:04 -04:00

44 lines
1.6 KiB
TypeScript

import CommandLine from './CommandLine';
// Example configuration object matching your structure
const config = {
viewers: ["chrome", "firefox"],
publishers: [],
tests: ["test/tests/real-time", "test/tests/dash", "test/tests/hls"],
useBrowserstack: false,
useBrowserstackLocal: false,
browserstackUser: "",
browserstackKey: "",
logLevel: "Info",
applicationId: "phenixrts.com-alex.zinn",
secret: "AMAsDzr.dIuGMZ.Zu52Dt~MQvP!DZwYg",
pcastUri: "https://pcast-stg.phenixrts.com",
ingestUri: "rtmp://ingest-stg.phenixrts.com:80/ingest",
channelUri: "https://pcast-stg.phenixrts.com/channel",
};
// Convert configuration to command line arguments
const args = CommandLine.configToArgs(config);
console.log('Generated command line arguments:');
console.log(args.join(' '));
console.log('\nThis generates the equivalent of:');
console.log('--application-id phenixrts.com-alex.zinn \\');
console.log('--secret AMAsDzr.dIuGMZ.Zu52Dt~MQvP!DZwYg \\');
console.log('--pcast-uri https://pcast-stg.phenixrts.com \\');
console.log('--channel-uri https://pcast-stg.phenixrts.com/channel \\');
console.log('--ingest-uri rtmp://ingest-stg.phenixrts.com:80/ingest \\');
console.log('--viewer chrome \\');
console.log('--viewer firefox \\');
console.log('--test test/tests/real-time \\');
console.log('--test test/tests/dash \\');
console.log('--test test/tests/hls \\');
console.log('--log-level Info');
console.log('\nNote: Users can pass --viewer, --publisher, and -t multiple times to build arrays');
// You can now use these arguments with the CommandLine.parse method
// const options = CommandLine.parse(args);
// console.log('Parsed options:', options);