* Registers all available commands on the program.
(program: Command)
| 149 | * Registers all available commands on the program. |
| 150 | */ |
| 151 | function registerCommands(program: Command): void { |
| 152 | // Inspect command - for inspecting and displaying .deepnote file metadata |
| 153 | program |
| 154 | .command('inspect') |
| 155 | .description('Inspect and display metadata from a .deepnote file') |
| 156 | .argument('[path]', 'Path to a .deepnote file or directory (defaults to current directory)') |
| 157 | .option( |
| 158 | '-o, --output <format>', |
| 159 | 'Output format: json, toon, llm', |
| 160 | createFormatValidator(OUTPUT_FORMATS, TOON_LLM_RESOLUTION) |
| 161 | ) |
| 162 | .addHelpText('after', () => { |
| 163 | const c = getChalk() |
| 164 | return ` |
| 165 | ${c.bold('Output:')} |
| 166 | Displays structured information about the .deepnote file including: |
| 167 | - File path and project name |
| 168 | - Project ID and file format version |
| 169 | - Creation, modification, and export timestamps |
| 170 | - Number of notebooks and total blocks |
| 171 | - List of notebooks with their block counts |
| 172 | |
| 173 | ${getSmartFileDiscoveryHelp(c)} |
| 174 | |
| 175 | ${c.bold('Examples:')} |
| 176 | ${c.dim('# Inspect first .deepnote file in current directory')} |
| 177 | $ deepnote inspect |
| 178 | |
| 179 | ${c.dim('# Inspect a specific .deepnote file')} |
| 180 | $ deepnote inspect my-project.deepnote |
| 181 | |
| 182 | ${c.dim('# Inspect first .deepnote file in a subdirectory')} |
| 183 | $ deepnote inspect notebooks/ |
| 184 | |
| 185 | ${c.dim('# Output as JSON for scripting')} |
| 186 | $ deepnote inspect my-project.deepnote -o json |
| 187 | |
| 188 | ${c.dim('# Output as TOON for LLM consumption (30-60% fewer tokens)')} |
| 189 | $ deepnote inspect my-project.deepnote -o toon |
| 190 | |
| 191 | ${c.dim('# Use with jq for specific fields')} |
| 192 | $ deepnote inspect my-project.deepnote -o json | jq '.project.name' |
| 193 | ` |
| 194 | }) |
| 195 | .action(createInspectAction(program)) |
| 196 | |
| 197 | // Cat command - display block contents from a .deepnote file |
| 198 | program |
| 199 | .command('cat') |
| 200 | .description('Display block contents from a .deepnote file') |
| 201 | .argument('<path>', 'Path to a .deepnote file') |
| 202 | .option('-o, --output <format>', 'Output format: json, llm', createFormatValidator(['json'], JSON_LLM_RESOLUTION)) |
| 203 | .option('--notebook <name>', 'Show only blocks from the specified notebook') |
| 204 | .option('--type <type>', `Filter blocks by type (${FILTERABLE_BLOCK_TYPES.join(', ')})`, createBlockTypeValidator()) |
| 205 | .option('--tree', 'Show structure only without block content') |
| 206 | .addHelpText('after', () => { |
| 207 | const c = getChalk() |
| 208 | return ` |
no test coverage detected