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

Khaled Garbaya
InstructorKhaled Garbaya

Share this video with your friends

Send Tweet

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.