forked from patternfly/patternfly-mcp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
38 lines (31 loc) · 1.05 KB
/
Copy pathindex.ts
File metadata and controls
38 lines (31 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env node
import { freezeOptions, parseCliOptions, type CliOptions } from './options';
import { runServer } from './server';
/**
* Main function - CLI entry point with optional programmatic overrides
*
* @param programmaticOptions - Optional programmatic options that override CLI options
*/
const main = async (programmaticOptions?: Partial<CliOptions>): Promise<void> => {
try {
// Parse CLI options
const cliOptions = parseCliOptions();
// Merge programmatic options with CLI options (programmatic takes precedence)
const finalOptions = { ...cliOptions, ...programmaticOptions };
// Freeze options to prevent further changes
freezeOptions(finalOptions);
// Create and run the server
await runServer();
} catch (error) {
console.error('Failed to start server:', error);
process.exit(1);
}
};
// Start the server
if (process.env.NODE_ENV !== 'local') {
main().catch(error => {
console.error('Failed to start server:', error);
process.exit(1);
});
}
export { main, main as start, type CliOptions };