commander#InvalidOptionArgumentError TypeScript Examples
The following examples show how to use
commander#InvalidOptionArgumentError.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: main.ts From squid with GNU General Public License v3.0 | 6 votes |
function urlOptionValidator(protocol?: string[]): (s: string) => string {
return function (s) {
let url
try {
url = new URL(s)
} catch(e: any) {
throw new InvalidOptionArgumentError('invalid url')
}
if (protocol && !protocol.includes(url.protocol)) {
throw new InvalidOptionArgumentError(`invalid protocol, expected ${protocol.join(', ')}`)
}
return url.toString()
}
}