* Print blocks to stdout with formatting.
( absolutePath: string, notebooks: DeepnoteFile['project']['notebooks'], options: CatOptions )
| 155 | * Print blocks to stdout with formatting. |
| 156 | */ |
| 157 | async function printBlocks( |
| 158 | absolutePath: string, |
| 159 | notebooks: DeepnoteFile['project']['notebooks'], |
| 160 | options: CatOptions |
| 161 | ): Promise<void> { |
| 162 | const chalk = getChalk() |
| 163 | output(chalk.dim(`File: ${absolutePath}`)) |
| 164 | output('') |
| 165 | |
| 166 | for (let i = 0; i < notebooks.length; i++) { |
| 167 | const notebook = notebooks[i] |
| 168 | const filteredBlocks = filterBlocks(notebook.blocks, options) |
| 169 | |
| 170 | // Add divider between notebooks (not before the first one) |
| 171 | if (i > 0) { |
| 172 | output('') |
| 173 | output(chalk.cyan('═'.repeat(60))) |
| 174 | output('') |
| 175 | } |
| 176 | |
| 177 | output(chalk.bold.cyan(`Notebook: ${notebook.name}`)) |
| 178 | output(chalk.dim(` ID: ${notebook.id}`)) |
| 179 | output(chalk.dim(` Blocks: ${filteredBlocks.length}`)) |
| 180 | output('') |
| 181 | |
| 182 | for (const block of filteredBlocks) { |
| 183 | await printBlock(block, options) |
| 184 | } |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | /** |
| 189 | * Print a single block with formatting. |
no test coverage detected