There's a faster version of egghead. Click here to try it.
1×
Become a member
to unlock all features

Create an egghead account to access 5000+ tutorials and resources from expert developers.

Create account
Autoplay

    Reduce Boilerplate with yargs middleware in a Node.js Command Line Tool

    nodeNode.js

    Sometimes you might want to transform arguments before they reach the command handler. For example, perhaps you want to validate that credentials have been provided and otherwise load credentials from a file.

    Middleware is simply a stack of functions, each of which is passed the current parsed arguments, which it can in turn update by adding values, removing values, or overwriting values.