clean up
This commit is contained in:
@@ -27,43 +27,61 @@ const defaultUseBrowserstack = false;
|
||||
const defaultUseBrowserstackLocal = false;
|
||||
|
||||
export default class CommandLine {
|
||||
private static readonly _program: Command = new Command();
|
||||
private static readonly _program: Command = new Command();
|
||||
|
||||
public static parse(args: string[]): CommandLineOptions {
|
||||
CommandLine._program.parse(args);
|
||||
|
||||
return CommandLine._program.opts<CommandLineOptions>();
|
||||
const rawOptions = CommandLine._program.opts();
|
||||
|
||||
// Convert the string log level back to LoggingLevel enum
|
||||
const logLevel = rawOptions.logLevel ? LoggingLevelMapping.convertLoggingLevelTypeToLoggingLevel(rawOptions.logLevel) : defaultLogLevel;
|
||||
|
||||
return {
|
||||
...rawOptions,
|
||||
logLevel
|
||||
} as CommandLineOptions;
|
||||
}
|
||||
|
||||
|
||||
static {
|
||||
CommandLine._program.version(PackageJson.version);
|
||||
|
||||
|
||||
const setupProgramOptions = (): void => {
|
||||
const handleArrayOption = (value: string, previousValue: string[]) => {
|
||||
if (previousValue) {
|
||||
return previousValue.concat(value);
|
||||
}
|
||||
|
||||
|
||||
return [value];
|
||||
};
|
||||
|
||||
|
||||
// Required options
|
||||
CommandLine._program.requiredOption('--application-id <applicationId>', 'The application ID to use');
|
||||
CommandLine._program.requiredOption('--secret <secret>', 'The secret to use');
|
||||
CommandLine._program.requiredOption('--pcast-uri <pcastUri>', 'The pcast URI to use');
|
||||
CommandLine._program.requiredOption('--channel-uri <channelUri>', 'The channel URI to use');
|
||||
|
||||
|
||||
CommandLine._program.option('--ingest-uri <ingestUri>', 'The ingest URI to use');
|
||||
CommandLine._program.option('--publisher-uri <publisherUri>', 'The publisher URI to use');
|
||||
CommandLine._program.option('--viewer <browser@version:OS@OSVersion...>', 'The browser and OS for simulating a viewer to use', handleArrayOption, defaultViewers);
|
||||
CommandLine._program.option('--publisher <browser@version:OS@OSVersion...>', 'The browser and OS for simulating a publisher to use', handleArrayOption, defaultPublishers);
|
||||
CommandLine._program.option(
|
||||
'--viewer <browser@version:OS@OSVersion...>',
|
||||
'The browser and OS for simulating a viewer to use',
|
||||
handleArrayOption,
|
||||
defaultViewers
|
||||
);
|
||||
CommandLine._program.option(
|
||||
'--publisher <browser@version:OS@OSVersion...>',
|
||||
'The browser and OS for simulating a publisher to use',
|
||||
handleArrayOption,
|
||||
defaultPublishers
|
||||
);
|
||||
CommandLine._program.option('-t, --test <test...>', 'The test to run', handleArrayOption, defaultTests);
|
||||
CommandLine._program.option('--use-browserstack', 'Run tests using BrowserStack', defaultUseBrowserstack);
|
||||
CommandLine._program.option('--use-browserstack-local', 'Run tests using BrowserStack Local', defaultUseBrowserstackLocal);
|
||||
CommandLine._program.option('--browserstack-user <username>', 'The BrowserStack username to use', process.env.BROWSERSTACK_USER || '');
|
||||
CommandLine._program.option('--browserstack-key <key>', 'The BrowserStack key to use', process.env.BROWSERSTACK_KEY || '');
|
||||
CommandLine._program.option('--log-level <logLevel>', 'The log level to use', LoggingLevelMapping.convertLoggingLevelToLoggingLevelType(defaultLogLevel));
|
||||
}
|
||||
};
|
||||
|
||||
setupProgramOptions();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user