usage.d.ts 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import { Dictionary } from './common-types';
  2. import { YargsInstance } from './yargs';
  3. import { YError } from './yerror';
  4. import { Y18N } from 'y18n';
  5. export declare function usage(yargs: YargsInstance, y18n: Y18N): UsageInstance;
  6. /** Instance of the usage module. */
  7. export interface UsageInstance {
  8. cacheHelpMessage(): void;
  9. clearCachedHelpMessage(): void;
  10. command(cmd: string, description: string | undefined, isDefault: boolean, aliases: string[], deprecated?: boolean): void;
  11. deferY18nLookup(str: string): string;
  12. describe(keys: string | string[] | Dictionary<string>, desc?: string): void;
  13. epilog(msg: string): void;
  14. example(cmd: string, description?: string): void;
  15. fail(msg?: string | null, err?: YError | string): void;
  16. failFn(f: FailureFunction): void;
  17. freeze(): void;
  18. functionDescription(fn: {
  19. name?: string;
  20. }): string;
  21. getCommands(): [string, string, boolean, string[], boolean][];
  22. getDescriptions(): Dictionary<string | undefined>;
  23. getPositionalGroupName(): string;
  24. getUsage(): [string, string][];
  25. getUsageDisabled(): boolean;
  26. help(): string;
  27. reset(localLookup: Dictionary<boolean>): UsageInstance;
  28. showHelp(level: 'error' | 'log' | ((message: string) => void)): void;
  29. showHelpOnFail(enabled?: boolean | string, message?: string): UsageInstance;
  30. showVersion(): void;
  31. stringifiedValues(values?: any[], separator?: string): string;
  32. unfreeze(): void;
  33. usage(msg: string | null, description?: string | false): UsageInstance;
  34. version(ver: any): void;
  35. wrap(cols: number | null | undefined): void;
  36. }
  37. export interface FailureFunction {
  38. (msg: string | undefined | null, err: YError | string | undefined, usage: UsageInstance): void;
  39. }
  40. export interface FrozenUsageInstance {
  41. failMessage: string | undefined | null;
  42. failureOutput: boolean;
  43. usages: [string, string][];
  44. usageDisabled: boolean;
  45. epilogs: string[];
  46. examples: [string, string][];
  47. commands: [string, string, boolean, string[], boolean][];
  48. descriptions: Dictionary<string | undefined>;
  49. }