Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

32 linhas
764B

  1. declare const flagSymbol: unique symbol;
  2. declare function arg<T extends arg.Spec>(spec: T, options?: arg.Options): arg.Result<T>;
  3. declare namespace arg {
  4. export function flag<T>(fn: T): T & { [flagSymbol]: true };
  5. export const COUNT: Handler<number> & { [flagSymbol]: true };
  6. export type Handler <T = any> = (value: string, name: string, previousValue?: T) => T;
  7. export interface Spec {
  8. [key: string]: string | Handler | [Handler];
  9. }
  10. export type Result<T extends Spec> = { _: string[] } & {
  11. [K in keyof T]?: T[K] extends Handler
  12. ? ReturnType<T[K]>
  13. : T[K] extends [Handler]
  14. ? Array<ReturnType<T[K][0]>>
  15. : never
  16. };
  17. export interface Options {
  18. argv?: string[];
  19. permissive?: boolean;
  20. stopAtPositional?: boolean;
  21. }
  22. }
  23. export = arg;