swc/crates/swc_bundler/tests/.cache/deno/53ef97cc19ddbc4e5d1af12c8f1ff41cceee0f48.ts
2021-11-09 20:42:49 +09:00

18 lines
534 B
TypeScript

// Loaded from https://deno.land/x/cliffy@v0.12.1/packages/flags/lib/types/boolean.ts
import { IFlagArgument, IFlagOptions, ITypeHandler } from '../types.ts';
export const boolean: ITypeHandler<boolean> = ( option: IFlagOptions, arg: IFlagArgument, value: string ): boolean => {
if ( ~[ '1', 'true' ].indexOf( value ) ) {
return true;
}
if ( ~[ '0', 'false' ].indexOf( value ) ) {
return false;
}
throw new Error( `Option --${ option.name } must be of type boolean but got: ${ value }` );
};