Enhance CommandLine and LoggerFactory for better type safety and clarity
* Further refined `CommandLine` class to ensure consistent use of `CommandLineOptions`. * Improved method organization in command line option setup for better readability. * Updated `LoggerFactory` to utilize `LoggingLevel` directly in logging level management, streamlining the process.
This commit is contained in:
@@ -34,62 +34,7 @@ export default class CommandLine {
|
||||
|
||||
return CommandLine._program.opts<CommandLineOptions>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a configuration object to command line arguments array
|
||||
*/
|
||||
public static configToArgs(config: CommandLineOptions): string[] {
|
||||
const args: string[] = [];
|
||||
|
||||
// Required options
|
||||
args.push('--application-id', config.applicationId);
|
||||
args.push('--secret', config.secret);
|
||||
args.push('--pcast-uri', config.pcastUri);
|
||||
args.push('--channel-uri', config.channelUri);
|
||||
|
||||
// Optional URI options
|
||||
if (config.publisherUri) {
|
||||
args.push('--publisher-uri', config.publisherUri);
|
||||
}
|
||||
if (config.ingestUri) {
|
||||
args.push('--ingest-uri', config.ingestUri);
|
||||
}
|
||||
|
||||
// Browser and OS options (singular option names, multiple values)
|
||||
config.viewers.forEach(viewer => {
|
||||
args.push('--viewer', viewer);
|
||||
});
|
||||
config.publishers.forEach(publisher => {
|
||||
args.push('--publisher', publisher);
|
||||
});
|
||||
|
||||
// Test options (singular option name, multiple values)
|
||||
config.tests.forEach(test => {
|
||||
args.push('--test', test);
|
||||
});
|
||||
|
||||
// BrowserStack options
|
||||
if (config.useBrowserstack) {
|
||||
args.push('--use-browserstack');
|
||||
}
|
||||
if (config.useBrowserstackLocal) {
|
||||
args.push('--use-browserstack-local');
|
||||
}
|
||||
if (config.browserstackUser) {
|
||||
args.push('--browserstack-user', config.browserstackUser);
|
||||
}
|
||||
if (config.browserstackKey) {
|
||||
args.push('--browserstack-key', config.browserstackKey);
|
||||
}
|
||||
|
||||
// Logging options
|
||||
if (config.logLevel) {
|
||||
args.push('--log-level', LoggingLevelMapping.convertLoggingLevelToLoggingLevelType(config.logLevel));
|
||||
}
|
||||
|
||||
return args;
|
||||
}
|
||||
|
||||
|
||||
static {
|
||||
CommandLine._program.version(PackageJson.version);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user