title: Proper way to make callbacks async by wrapping them using `co`?
body: <p>It is 2016, Node has had nearly full ES6 support since v4, and Promises have been around since 0.12. It's time to leave callbacks in the dust IMO.</p>
  
  <p>I'm working on a <a href="https://github.com/tj/commander.js" rel="nofollow">commander.js</a>-based CLI util which leverages a lot of async operations - http requests and user input. I want to wrap the Commander <code>action</code>s in async functions so that they can be treated as promises, and also to support generators (useful for the <code>co-prompt</code> library I'm using for user input).</p>
  
  <p>I've tried wrapping the CB with <code>co</code> in two ways:</p>
  
  <p>1)
  <code>
      program.command('myCmd')
          .action(program =&gt; co(function* (program) {...})
          .catch(err =&gt; console.log(err.stack)) );
  </code></p>
  
  <p>and </p>
  
  <p>2) <code>program.command('myCmd').action(co.wrap(function* (program) { .. }));</code></p>
  
  <p>The problem with 1) is that the <code>program</code> parameter isn't passed</p>
  
  <p>The problem with 2) is that errors are swallowed...</p>
  
  <p>I'd really like to get this working as it yields much nicer code in my use case - involving a lot of http requests and also waiting for user input using the <code>co-prompt</code> library..</p>
  
  <p>Is it a better option altogether perhaps to wrap <code>program.Command.prototype.action</code> somehow?</p>
  
  <p>thanks!</p>