@emailcheck/email-validator-js
Version:
Advanced email validation with MX records, SMTP verification, disposable email detection, batch processing, and caching. Production-ready with TypeScript support.
51 lines (50 loc) • 1.57 kB
TypeScript
/**
* Minimal flag parser for the `email-validate` CLI.
*
* Accepts `argv` (everything after `node bin / email-validate`) and produces a
* `ParsedArgs` shape, or throws a `CliArgError` with `messages[]` and an
* `exitCode` for the caller to propagate.
*
* Why hand-rolled: the CLI surface is small (~15 flags), and pulling in
* `commander` / `yargs` would balloon the published bundle for every consumer
* regardless of whether they ever run the CLI. The trade-off is no
* sub-command tree — just one flat command — which fits the tool fine.
*/
export interface ParsedArgs {
/** Email address to validate (positional). */
email: string;
verifyMx: boolean;
verifySmtp: boolean;
ports?: number[];
smtpPort?: number;
hostname?: string;
timeoutMs?: number;
checkDisposable: boolean;
checkFree: boolean;
suggestDomain: boolean;
detectName: boolean;
checkDomainAge: boolean;
checkDomainRegistration: boolean;
whoisTimeoutMs?: number;
format: 'text' | 'json' | 'pretty';
quiet: boolean;
debug: boolean;
captureTranscript: boolean;
logDir: string | null;
}
export interface ParsedHelp {
kind: 'help';
}
export interface ParsedVersion {
kind: 'version';
}
export interface CliArgError {
kind: 'error';
messages: string[];
exitCode: number;
}
export type ParseResult = ({
kind: 'args';
} & ParsedArgs) | ParsedHelp | ParsedVersion | CliArgError;
export declare function parseArgs(argv: readonly string[]): ParseResult;
export declare function helpText(): string;