Skip to content

Commit

Permalink
docs: add README.md for countEntriesInDirectory
Browse files Browse the repository at this point in the history
  • Loading branch information
bnb committed Apr 2, 2020
1 parent 46dd809 commit 1fcc9a4
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions cli/yargs/countEntriesInDirectory/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# countEntriesInDirectory

This is a CLI built with [yargs](https://www.npmjs.com/package/yargs) that searches the directory (path) passed to it and then spits out how many entries (files and directories) are within _that directory_. It does not recursively search additional directories within it.

## Usage

Here is the output of running `node bin/cli.js -h` from the `countEntriesInDirectory` directory:

```bash
Usage: cli.js --directory=[path to a directory]

Options:
--help Show help [boolean]
--version Show version number [boolean]
--directory, -d the directory to count files within. [required]
```

### As a Local Project

You'll want to start by installing dependencies:

```
npm install
```

Since this is a CLI, you'll probably want to get it available on your PATH. There's two ways you can do this:

**Via global installation:**

```bash
npm i -g . # this will install the current working directory as a global module. you will want to do npm uninstall -g . to uninstall it.
countEntriesInDirectory --directory=. # run the CLI
```

**Via symlink:**

```bash
npm link # this will create a symlink that makes the module act as a global module. npm unlink to remove this.
countEntriesInDirectory --directory=. # run the CLI
```

### As a Module Published to npm

If you were to pulbish this CLI to npm, there'd be two ways you'd use it from the registry with npm (let's assume you published as `count-entries-in-directory`):

```bash
npm i -g count-entries-in-directory # this would install the module from the registry and make it globally available
countEntriesInDirectory --directory=. # run the CLI
```

```bash
npx count-entries-in-directory --directory=. # this would temporarily download the module, run the first entry in `bin` of package.json and pass along any additional arguments like `--directory=.`
```

0 comments on commit 1fcc9a4

Please sign in to comment.