default.renderer.d.ts 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. import { ListrRenderer } from '../interfaces/renderer.interface';
  2. import { Task } from '../lib/task';
  3. /** Default updating renderer for Listr2 */
  4. export declare class DefaultRenderer implements ListrRenderer {
  5. tasks: Task<any, typeof DefaultRenderer>[];
  6. options: typeof DefaultRenderer['rendererOptions'];
  7. renderHook$?: Task<any, any>['renderHook$'];
  8. /** designates whether this renderer can output to a non-tty console */
  9. static nonTTY: boolean;
  10. /** renderer options for the defauult renderer */
  11. static rendererOptions: {
  12. /**
  13. * indentation per level of subtask
  14. *
  15. * @default 2
  16. */
  17. indentation?: number;
  18. /**
  19. * clear all the output generated by the renderer when the task finishes its execution
  20. *
  21. * @default false
  22. * @global global option that can not be temperated with subtasks
  23. */
  24. clearOutput?: boolean;
  25. /**
  26. * show the subtasks of the current task
  27. *
  28. * @default true
  29. */
  30. showSubtasks?: boolean;
  31. /**
  32. * collapse subtasks after current task completes its execution
  33. *
  34. * @default true
  35. */
  36. collapse?: boolean;
  37. /**
  38. * show skip messages or show the original title of the task, this will also disable collapseSkips mode
  39. *
  40. * You can disable showing the skip messages, even though you passed in a message by settings this option,
  41. * if you want to keep the original task title intact.
  42. *
  43. * @default true
  44. */
  45. showSkipMessage?: boolean;
  46. /**
  47. * collapse skip messages into a single message and overwrite the task title
  48. *
  49. * @default true
  50. */
  51. collapseSkips?: boolean;
  52. /**
  53. * suffix skip messages with [SKIPPED] when in collapseSkips mode
  54. *
  55. * @default true
  56. */
  57. suffixSkips?: boolean;
  58. /**
  59. * shows the thrown error message or show the original title of the task, this will also disable collapseErrors mode
  60. * You can disable showing the error messages, even though you passed in a message by settings this option,
  61. * if you want to keep the original task title intact.
  62. *
  63. * @default true
  64. */
  65. showErrorMessage?: boolean;
  66. /**
  67. * collapse error messages into a single message and overwrite the task title
  68. *
  69. * @default true
  70. */
  71. collapseErrors?: boolean;
  72. /**
  73. * suffix retry messages with [RETRY-${COUNT}] when retry is enabled for a task
  74. *
  75. * @default true
  76. */
  77. suffixRetries?: boolean;
  78. /**
  79. * only update through triggers from renderhook
  80. *
  81. * useful for tests and stuff. this will disable showing spinner and only update the screen if something else has
  82. * happened in the task worthy to show
  83. *
  84. * @default false
  85. * @global global option that can not be temperated with subtasks
  86. */
  87. lazy?: boolean;
  88. /**
  89. * show duration for all tasks
  90. *
  91. * @default false
  92. * @global global option that can not be temperated with subtasks
  93. */
  94. showTimer?: boolean;
  95. /**
  96. * removes empty lines from the data output
  97. *
  98. * @default true
  99. */
  100. removeEmptyLines?: boolean;
  101. /**
  102. * formats data output depending on your requirements.
  103. *
  104. * @default 'truncate'
  105. * @global global option that can not be temperated with subtasks
  106. */
  107. formatOutput?: 'truncate' | 'wrap';
  108. };
  109. /** per task options for the default renderer */
  110. static rendererTaskOptions: {
  111. /**
  112. * write task output to the bottom bar instead of the gap under the task title itself.
  113. * useful for a stream of data.
  114. * @default false
  115. *
  116. * `true` only keep 1 line of the latest data outputted by the task.
  117. * `false` only keep 1 line of the latest data outputted by the task.
  118. * `number` will keep designated data of the latest data outputted by the task.
  119. */
  120. bottomBar?: boolean | number;
  121. /**
  122. * keep output after task finishes
  123. * @default false
  124. *
  125. * works both for the bottom bar and the default behavior
  126. */
  127. persistentOutput?: boolean;
  128. /**
  129. * show the task time if it was successful
  130. */
  131. showTimer?: boolean;
  132. };
  133. private id?;
  134. private bottomBar;
  135. private promptBar;
  136. private readonly spinner;
  137. private spinnerPosition;
  138. constructor(tasks: Task<any, typeof DefaultRenderer>[], options: typeof DefaultRenderer['rendererOptions'], renderHook$?: Task<any, any>['renderHook$']);
  139. getTaskOptions(task: Task<any, typeof DefaultRenderer>): typeof DefaultRenderer['rendererTaskOptions'];
  140. isBottomBar(task: Task<any, typeof DefaultRenderer>): boolean;
  141. hasPersistentOutput(task: Task<any, typeof DefaultRenderer>): boolean;
  142. hasTimer(task: Task<any, typeof DefaultRenderer>): boolean;
  143. getSelfOrParentOption<T extends keyof typeof DefaultRenderer['rendererOptions']>(task: Task<any, typeof DefaultRenderer>, key: T): typeof DefaultRenderer['rendererOptions'][T];
  144. getTaskTime(task: Task<any, typeof DefaultRenderer>): string;
  145. createRender(options?: {
  146. tasks?: boolean;
  147. bottomBar?: boolean;
  148. prompt?: boolean;
  149. }): string;
  150. render(): void;
  151. end(): void;
  152. private multiLineRenderer;
  153. private renderBottomBar;
  154. private renderPrompt;
  155. private dumpData;
  156. private formatString;
  157. private indentMultilineOutput;
  158. private getSymbol;
  159. private addSuffixToMessage;
  160. }