|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
891 bytes
|
| Line | |
|---|
| 1 | declare function arg<T extends arg.Spec>(
|
|---|
| 2 | spec: T,
|
|---|
| 3 | options?: arg.Options
|
|---|
| 4 | ): arg.Result<T>;
|
|---|
| 5 |
|
|---|
| 6 | declare namespace arg {
|
|---|
| 7 | export const flagSymbol: unique symbol;
|
|---|
| 8 |
|
|---|
| 9 | export function flag<T>(fn: T): T & { [arg.flagSymbol]: true };
|
|---|
| 10 |
|
|---|
| 11 | export const COUNT: Handler<number> & { [arg.flagSymbol]: true };
|
|---|
| 12 |
|
|---|
| 13 | export type Handler<T = any> = (
|
|---|
| 14 | value: string,
|
|---|
| 15 | name: string,
|
|---|
| 16 | previousValue?: T
|
|---|
| 17 | ) => T;
|
|---|
| 18 |
|
|---|
| 19 | export class ArgError extends Error {
|
|---|
| 20 | constructor(message: string, code: string);
|
|---|
| 21 |
|
|---|
| 22 | code: string;
|
|---|
| 23 | }
|
|---|
| 24 |
|
|---|
| 25 | export interface Spec {
|
|---|
| 26 | [key: string]: string | Handler | [Handler];
|
|---|
| 27 | }
|
|---|
| 28 |
|
|---|
| 29 | export type Result<T extends Spec> = { _: string[] } & {
|
|---|
| 30 | [K in keyof T]?: T[K] extends Handler
|
|---|
| 31 | ? ReturnType<T[K]>
|
|---|
| 32 | : T[K] extends [Handler]
|
|---|
| 33 | ? Array<ReturnType<T[K][0]>>
|
|---|
| 34 | : never;
|
|---|
| 35 | };
|
|---|
| 36 |
|
|---|
| 37 | export interface Options {
|
|---|
| 38 | argv?: string[];
|
|---|
| 39 | permissive?: boolean;
|
|---|
| 40 | stopAtPositional?: boolean;
|
|---|
| 41 | }
|
|---|
| 42 | }
|
|---|
| 43 |
|
|---|
| 44 | export = arg;
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.