title: Why do the major node arg parsers use chaining syntax?
body: <p>Both <a href="https://github.com/tj/commander.js" rel="nofollow noreferrer">commander</a> and <a href="https://github.com/yargs/yargs" rel="nofollow noreferrer">yargs</a> use a chaining syntax that is reminiscent of jQuery.</p>
  <p>Is the chaining syntax a historical outcome of the era in which the libraries were created, or is there a functional motivation?</p>
  <p>Trying to decide whether to write a wrapper with my preferred syntax or not.</p>
  <p><strong>commander</strong>:</p>
  <pre class="lang-js prettyprint-override"><code>program
    .option('-d, --debug', 'output extra debugging')
    .option('-s, --small', 'small pizza size')
    .option('-p, --pizza-type &lt;type&gt;', 'flavour of pizza');
  
  program.parse(process.argv);
  </code></pre>
  <p><strong>yargs</strong>:</p>
  <pre class="lang-js prettyprint-override"><code>yargs(hideBin(process.argv))
    .command('serve [port]', 'start the server', (yargs) =&gt; {
      yargs
        .positional('port', {
          describe: 'port to bind on',
          default: 5000
        })
    }, (argv) =&gt; {
      if (argv.verbose) console.info(`start server on :${argv.port}`)
      serve(argv.port)
    })
    .option('verbose', {
      alias: 'v',
      type: 'boolean',
      description: 'Run with verbose logging'
    })
    .argv
  </code></pre>
  <p>They could instead, for example, accept one large configuration object, which seems more idiomatic:</p>
  <pre class="lang-js prettyprint-override"><code>parse({
    options: {
      debug: {
        description: 'output extra debugging',
        alias: 'd'
      },
      small: {
        description: 'small pizza size',
        alias: 's'
      },
      ['pizza-type']: {
        description: 'flavour of pizza',
        alias: 'p'
      },
    }
  })
  </code></pre>