|
| 1 | +// Type definitions for tabtab 0.0.4 |
| 2 | +// Project: https://github.com/mklabs/node-tabtab |
| 3 | +// Definitions by: Vojtěch Habarta <https://github.com/vojtechhabarta> |
| 4 | +// Definitions: https://github.com/borisyankov/DefinitelyTyped |
| 5 | + |
| 6 | +declare module "tabtab" { |
| 7 | + |
| 8 | + /** |
| 9 | + * Main completion method, has support for installation and actual completion. |
| 10 | + * @param name Name of the command to complete. |
| 11 | + * @param cb Get called when a tab-completion command happens. |
| 12 | + */ |
| 13 | + export function complete(name: string, cb: CallBack): void; |
| 14 | + |
| 15 | + /** |
| 16 | + * Main completion method, has support for installation and actual completion. |
| 17 | + * @param name Name of the command to complete. |
| 18 | + * @param completer Name of the command to call on completion. |
| 19 | + * @param cb Get called when a tab-completion command happens. |
| 20 | + */ |
| 21 | + export function complete(name: string, completer: string, cb: CallBack): void; |
| 22 | + |
| 23 | + /** |
| 24 | + * Simple helper function to know if the script is run in the context of a completion command. |
| 25 | + */ |
| 26 | + export function isComplete(): boolean; |
| 27 | + |
| 28 | + /** |
| 29 | + * Helper to return the list of short and long options, parsed from the usual --help output of a command (cake/rake -H, vagrant, commander -h, optimist.help(), ...). |
| 30 | + */ |
| 31 | + export function parseOut(str: string): { shorts: string[]; longs: string[] }; |
| 32 | + |
| 33 | + /** |
| 34 | + * Same purpose as parseOut, but for parsing tasks from an help command (cake/rake -T, vagrant, etc.). |
| 35 | + */ |
| 36 | + export function parseTasks(str: string, prefix: string, reg?: RegExp|string): string[]; |
| 37 | + |
| 38 | + /** |
| 39 | + * Helper to return completion output and log to standard output. |
| 40 | + * @param values Array of values to complete against. |
| 41 | + * @param data The data object returned by the complete callback, used mainly to filter results accordingly upon the text that is supplied by the user. |
| 42 | + * @param prefix A prefix to add to the completion results, useful for options to add dashes (eg. - or --). |
| 43 | + */ |
| 44 | + export function log(values: string[], data: Data, prefix?: string): void; |
| 45 | + |
| 46 | + interface CallBack { |
| 47 | + (error?: Error, data?: Data, text?: string): any; |
| 48 | + } |
| 49 | + |
| 50 | + /** |
| 51 | + * Holds interesting values to drive the output of the completion. |
| 52 | + */ |
| 53 | + interface Data { |
| 54 | + |
| 55 | + /** |
| 56 | + * full command being completed |
| 57 | + */ |
| 58 | + line: string; |
| 59 | + |
| 60 | + /** |
| 61 | + * number of words |
| 62 | + */ |
| 63 | + words: number; |
| 64 | + |
| 65 | + /** |
| 66 | + * cursor position |
| 67 | + */ |
| 68 | + point: number; |
| 69 | + |
| 70 | + /** |
| 71 | + * tabing in the middle of a word: foo bar baz bar foobarrrrrrr |
| 72 | + */ |
| 73 | + partial: string; |
| 74 | + |
| 75 | + /** |
| 76 | + * last word of the line |
| 77 | + */ |
| 78 | + last: string; |
| 79 | + |
| 80 | + /** |
| 81 | + * last partial of the line |
| 82 | + */ |
| 83 | + lastPartial: string; |
| 84 | + |
| 85 | + /** |
| 86 | + * the previous word |
| 87 | + */ |
| 88 | + prev: string; |
| 89 | + } |
| 90 | + |
| 91 | +} |
0 commit comments