Skip to content

Commit

Permalink
docs: describe commandDir() parameters (yargs#1540)
Browse files Browse the repository at this point in the history
  • Loading branch information
bennycode committed Apr 7, 2020
1 parent 9249295 commit 55fc090
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions docs/api.md
Expand Up @@ -193,6 +193,39 @@ var argv = require('yargs')
.argv
```

<a name="commandDir"></a>
.commandDir(directory, [opts])
------------------------------

Apply command modules from a directory relative to the module calling this method.

`directory` is a relative directory path as a string (required).

`opts` is an options object (optional). The following options are valid:

- `recurse`: boolean, default `false`

Look for command modules in all subdirectories and apply them as a flattened
(non-hierarchical) list.

- `extensions`: array of strings, default `['js']`

The types of files to look for when requiring command modules.

- `visit`: function

A synchronous function called for each command module encountered. Accepts
`commandObject`, `pathToFile`, and `filename` as arguments. Returns
`commandObject` to include the command; any falsy value to exclude/skip it.

- `include`: RegExp or function

Whitelist certain modules. See [`require-directory` whitelisting](https://www.npmjs.com/package/require-directory#whitelisting) for details.

- `exclude`: RegExp or function

Blacklist certain modules. See [`require-directory` blacklisting](https://www.npmjs.com/package/require-directory#blacklisting) for details.

<a name="command"></a>
.command(cmd, desc, [builder], [handler])
-----------------------------------------
Expand Down

0 comments on commit 55fc090

Please sign in to comment.