title: How to parse commandline args with yargs in typescript
body: <p>Here is what I tried (code adapted the code from the example in the yargs github readme): </p>
  
  <pre><code>// main.ts
  
  import {Argv} from "yargs";
  
  
  console.info(`CLI starter.`);
  
  function serve(port: string) {
      console.info(`Serve on port ${port}.`);
  }
  
  require('yargs')
      .command('serve', "Start the server.", (yargs: Argv) =&gt; {
          yargs.option('port', {
              describe: "Port to bind on",
              default: "5000",
          }).option('verbose', {
              alias: 'v',
              default: false,
          })
      }, (args: any) =&gt; {
          if (args.verbose) {
              console.info("Starting the server...");
          }
          serve(args.port);
      }).argv;
  </code></pre>
  
  <p>Results:</p>
  
  <pre><code>npm run-script build; node build/main.js --port=432 --verbose
  
  &gt; typescript-cli-starter@0.0.1 build /Users/kaiyin/WebstormProjects/typescript-cli-starter
  &gt; tsc -p .
  
  CLI starter.
  </code></pre>
  
  <p>Looks like yargs has no effects here. </p>
  
  <p>Any idea how to get this to work? </p>