All files / cli/src/commands docgen.ts

66.66% Statements 2/3
100% Branches 0/0
50% Functions 1/2
66.66% Lines 2/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19        5x       1x                    
import { writeOpenCliDocument, type DocumentFormat } from '@clidoc/core';
import { defineCommand } from 'yargs-file-commands';
import { cliDocument } from '../definition.js';
 
export const command = defineCommand({
  command: 'docgen',
  describe: 'Write the OpenCLI document describing this CLI',
  builder: (yargs) =>
    yargs
      .option('format', {
        type: 'string',
        choices: ['json', 'yaml', 'markdown'] as const,
        default: 'json',
        describe: 'Output format',
      })
      .option('output', { type: 'string', alias: 'o', describe: 'Output file; defaults to stdout' }),
  handler: (argv) => writeOpenCliDocument(cliDocument(), argv.output, argv.format as DocumentFormat),
});