title: CommanderJS - validate argument
body: <p>Given the following <code>cli</code> configuration, we can validate the arguments passed by simply putting an imperative control inside the action handler...</p>
  
  <pre class="lang-js prettyprint-override"><code>#!/usr/bin/env node
  
  var program = require('commander');
  
  program
    .command('greet &lt;person&gt;')
    .action((person, cmd) =&gt; {
      console.log(`Hello ${person}`);
    })
  
  program.parse(process.argv)
  </code></pre>
  
  
  
  <p>However, I was wondering if there were actual apis to do so:</p>
  
  <pre><code>program.command('greet &lt;Giuseppe|Mick|Bob&gt;');
  </code></pre>
  
  <p>So that <code>commanderjs</code> would automatically throw if arguments are incorrect.</p>