diff options
| author | Philipp Tanlak <philipp.tanlak@gmail.com> | 2025-11-24 20:54:57 +0100 |
|---|---|---|
| committer | Philipp Tanlak <philipp.tanlak@gmail.com> | 2025-11-24 20:57:48 +0100 |
| commit | b1e2c8fd5cb5dfa46bc440a12eafaf56cd844b1c (patch) | |
| tree | 49d360fd6cbc6a2754efe93524ac47ff0fbe0f7d /node_modules/arg/index.d.ts | |
Docs
Diffstat (limited to 'node_modules/arg/index.d.ts')
| -rw-r--r-- | node_modules/arg/index.d.ts | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/node_modules/arg/index.d.ts b/node_modules/arg/index.d.ts new file mode 100644 index 0000000..44f9f35 --- /dev/null +++ b/node_modules/arg/index.d.ts @@ -0,0 +1,44 @@ +declare function arg<T extends arg.Spec>( + spec: T, + options?: arg.Options +): arg.Result<T>; + +declare namespace arg { + export const flagSymbol: unique symbol; + + export function flag<T>(fn: T): T & { [arg.flagSymbol]: true }; + + export const COUNT: Handler<number> & { [arg.flagSymbol]: true }; + + export type Handler<T = any> = ( + value: string, + name: string, + previousValue?: T + ) => T; + + export class ArgError extends Error { + constructor(message: string, code: string); + + code: string; + } + + export interface Spec { + [key: string]: string | Handler | [Handler]; + } + + export type Result<T extends Spec> = { _: string[] } & { + [K in keyof T]?: T[K] extends Handler + ? ReturnType<T[K]> + : T[K] extends [Handler] + ? Array<ReturnType<T[K][0]>> + : never; + }; + + export interface Options { + argv?: string[]; + permissive?: boolean; + stopAtPositional?: boolean; + } +} + +export = arg; |