MCPcopy Create free account
hub / github.com/compiler-explorer/compiler-explorer / parsePortNumberForOptions

Function parsePortNumberForOptions

lib/app/cli.ts:38–49  ·  view source on GitHub ↗
(value: string)

Source from the content-addressed store, hash-verified

36 * Parses a command line option into a number.
37 */
38export function parsePortNumberForOptions(value: string): number {
39 // Ensure string contains only digits
40 if (!/^\d+$/.test(value)) {
41 throw new Error(`Invalid port number: "${value}"`);
42 }
43
44 const parsedValue = Number.parseInt(value, 10);
45 if (Number.isNaN(parsedValue) || parsedValue > 65535) {
46 throw new Error(`Invalid port number: "${value}"`);
47 }
48 return parsedValue;
49}
50
51/**
52 * Options parsed from command-line arguments

Callers 1

cli-tests.tsFile · 0.85

Calls 1

testMethod · 0.80

Tested by

no test coverage detected