completion.d.ts 994 B

123456789101112131415161718192021
  1. import { CommandInstance } from './command';
  2. import { UsageInstance } from './usage';
  3. import { YargsInstance } from './yargs';
  4. import { Arguments, DetailedArguments } from 'yargs-parser';
  5. export declare function completion(yargs: YargsInstance, usage: UsageInstance, command: CommandInstance): CompletionInstance;
  6. /** Instance of the completion module. */
  7. export interface CompletionInstance {
  8. completionKey: string;
  9. generateCompletionScript($0: string, cmd: string): string;
  10. getCompletion(args: string[], done: (completions: string[]) => any): any;
  11. registerFunction(fn: CompletionFunction): void;
  12. setParsed(parsed: DetailedArguments): void;
  13. }
  14. export declare type CompletionFunction = SyncCompletionFunction | AsyncCompletionFunction;
  15. interface SyncCompletionFunction {
  16. (current: string, argv: Arguments): string[] | Promise<string[]>;
  17. }
  18. interface AsyncCompletionFunction {
  19. (current: string, argv: Arguments, done: (completions: string[]) => any): any;
  20. }
  21. export {};