validation.d.ts 1.7 KB

12345678910111213141516171819202122232425262728293031323334
  1. import { Dictionary } from './common-types';
  2. import { UsageInstance } from './usage';
  3. import { YargsInstance, Arguments } from './yargs';
  4. import { DetailedArguments } from 'yargs-parser';
  5. import { Y18N } from 'y18n';
  6. export declare function validation(yargs: YargsInstance, usage: UsageInstance, y18n: Y18N): ValidationInstance;
  7. /** Instance of the validation module. */
  8. export interface ValidationInstance {
  9. check(f: CustomCheck['func'], global: boolean): void;
  10. conflicting(argv: Arguments): void;
  11. conflicts(key: string | Dictionary<string | string[]>, value?: string | string[]): void;
  12. customChecks(argv: Arguments, aliases: DetailedArguments['aliases']): void;
  13. freeze(): void;
  14. getConflicting(): Dictionary<(string | undefined)[]>;
  15. getImplied(): Dictionary<KeyOrPos[]>;
  16. implications(argv: Arguments): void;
  17. implies(key: string | Dictionary<KeyOrPos | KeyOrPos[]>, value?: KeyOrPos | KeyOrPos[]): void;
  18. isValidAndSomeAliasIsNotNew(key: string, aliases: DetailedArguments['aliases']): boolean;
  19. limitedChoices(argv: Arguments): void;
  20. nonOptionCount(argv: Arguments): void;
  21. positionalCount(required: number, observed: number): void;
  22. recommendCommands(cmd: string, potentialCommands: string[]): void;
  23. requiredArguments(argv: Arguments): void;
  24. reset(localLookup: Dictionary): ValidationInstance;
  25. unfreeze(): void;
  26. unknownArguments(argv: Arguments, aliases: DetailedArguments['aliases'], positionalMap: Dictionary, isDefaultCommand: boolean): void;
  27. unknownCommands(argv: Arguments): boolean;
  28. }
  29. interface CustomCheck {
  30. func: (argv: Arguments, aliases: DetailedArguments['aliases']) => any;
  31. global: boolean;
  32. }
  33. export declare type KeyOrPos = string | number;
  34. export {};