{
  "type": "module",
  "source": "doc/api/contributing-commands.md",
  "modules": [
    {
      "textRaw": "Creating Commands",
      "name": "creating_commands",
      "type": "module",
      "desc": "<p>The <code>doc-kit</code> CLI is built on <a href=\"https://www.npmjs.com/package/commander\">Commander</a>.\nEach command is a module in <code>packages/cli/bin/commands/</code> whose default export\nis a Commander <code>Command</code> instance; the CLI entry point registers every command\nexported from <code>packages/cli/bin/commands/index.mjs</code>.</p>\n<p>Today the CLI ships a single command, <a href=\"../cli.html\"><code>generate</code></a>.</p>",
      "modules": [
        {
          "textRaw": "Creating a New Command",
          "name": "creating_a_new_command",
          "type": "module",
          "modules": [
            {
              "textRaw": "Step 1: Create the Command File",
              "name": "step_1:_create_the_command_file",
              "type": "module",
              "desc": "<p>Create a new file in <code>packages/cli/bin/commands/</code> with your command name:</p>\n<pre><code class=\"language-mjs\">import { Command, Option } from 'commander';\n\nimport { errorWrap } from '../utils.mjs';\n\nexport default new Command('my-command')\n  .description('Does something useful')\n  .addOption(new Option('-f, --force', 'Force overwrite existing files'))\n  .action(\n    errorWrap(async opts => {\n      // Your command logic here\n    })\n  );\n</code></pre>\n<p><code>errorWrap</code> catches both synchronous and asynchronous errors, logs them, and\nexits with a non-zero status — wrap every action with it so failures are\nreported consistently.</p>",
              "displayName": "Step 1: Create the Command File"
            },
            {
              "textRaw": "Step 2: Register the Command",
              "name": "step_2:_register_the_command",
              "type": "module",
              "desc": "<p>Add your command to the exports in <code>packages/cli/bin/commands/index.mjs</code>:</p>\n<pre><code class=\"language-mjs\">import generate from './generate.mjs';\nimport myCommand from './my-command.mjs'; // Add this\n\nexport default [\n  generate,\n  myCommand, // Add this\n];\n</code></pre>\n<p>The CLI in <code>packages/cli/bin/cli.mjs</code> registers every command in that array,\nso no further changes are needed.</p>",
              "displayName": "Step 2: Register the Command"
            }
          ],
          "displayName": "Creating a New Command"
        },
        {
          "textRaw": "Command Options",
          "name": "command_options",
          "type": "module",
          "desc": "<p>Options use Commander's <code>Option</code> class directly; see the <a href=\"https://www.npmjs.com/package/commander#options\">Commander\ndocumentation</a> for the full\nAPI.</p>\n<pre><code class=\"language-js\">.addOption(new Option('-i, --input &#x3C;patterns...>', 'Input file patterns (glob)'))\n.addOption(new Option('-o, --output &#x3C;directory>', 'The output directory'))\n.addOption(\n  new Option('--log-level &#x3C;level>', 'Log level').choices(['debug', 'info'])\n)\n</code></pre>",
          "modules": [
            {
              "textRaw": "Flag Syntax",
              "name": "flag_syntax",
              "type": "module",
              "desc": "<ul>\n<li><code>&#x3C;value></code> - Required argument</li>\n<li><code>[value]</code> - Optional argument</li>\n<li><code>&#x3C;values...></code> - Variadic (multiple values)</li>\n<li><code>[values...]</code> - Optional variadic</li>\n</ul>\n<p>One global option, <code>--log-level</code>, is defined on the program itself in\n<code>packages/cli/bin/cli.mjs</code> and applies to every command.</p>",
              "displayName": "Flag Syntax"
            }
          ],
          "displayName": "Command Options"
        }
      ],
      "displayName": "Creating Commands"
    }
  ]
}