# inquirer-file-tree-selection-prompt

> inquerer file tree selection prompt

Latest version **2.0.5** (published 2022-10-08) · ISC license · 0 weekly downloads

## Install

```sh
npm install inquirer-file-tree-selection-prompt
pnpm add inquirer-file-tree-selection-prompt
yarn add inquirer-file-tree-selection-prompt
bun add inquirer-file-tree-selection-prompt
```

## Health

**Score 40/100 (D)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high maintenance score.

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 2.0.5 |
| Published | 2022-10-08 |
| First published | 2019-06-22 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=14.16 |
| Dependencies | 4 |
| Unpacked size | 26.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 50 |
| Author | anc95 |
| Maintainers | anc95 |
| Keywords | inquirer, filetree |

## Links

- npm: https://www.npmjs.com/package/inquirer-file-tree-selection-prompt
- Repository: https://github.com/anc95/inquirer-file-tree-selection
- Homepage: https://github.com/anc95/inquirer-file-tree-selection#readme
- Issues: https://github.com/anc95/inquirer-file-tree-selection/issues
- npm.io page: https://npm.io/package/inquirer-file-tree-selection-prompt

## Dependencies (4)

- [rxjs](https://npm.io/package/rxjs.md) ^7.5.6
- [chalk](https://npm.io/package/chalk.md) ^5.0.1
- [figures](https://npm.io/package/figures.md) ^4.0.1
- [cli-cursor](https://npm.io/package/cli-cursor.md) ^4.0.0

## Alternatives

- [localforage](https://npm.io/package/localforage.md) — 6.2M weekly downloads
- [localforage-observable](https://npm.io/package/localforage-observable.md) — 30.8K weekly downloads
- [@y/y](https://npm.io/package/@y/y.md) — 30.1K weekly downloads
- [@metaobjectsdev/render](https://npm.io/package/@metaobjectsdev/render.md) — 3.5K weekly downloads
- [@ledgerhq/coin-algorand](https://npm.io/package/@ledgerhq/coin-algorand.md) — 1.1K weekly downloads

## Recent versions

- 2.0.5 (latest) — 2022-10-08
- 2.0.3-test.0 (test) — 2022-08-05
- 2.0.4 — 2022-08-05
- 2.0.3 — 2022-08-05
- 2.0.2 — 2022-08-05
- 2.0.1 — 2022-08-05
- 2.0.0 — 2022-08-04
- 1.0.19 — 2022-04-13
- 1.0.18 — 2022-03-06
- 1.0.17 — 2022-03-06
- 1.0.16 — 2022-03-04
- 1.0.15 — 2022-01-17
- 1.0.14 — 2022-01-16
- 1.0.13 — 2021-10-31
- 1.0.12 — 2021-07-02
- … 10 more at https://npm.io/package/inquirer-file-tree-selection-prompt/versions

## README

## Inquirer File Tree Selection Prompt

[![Node.js Package](https://github.com/anc95/inquirer-file-tree-selection/actions/workflows/npm-publish.yml/badge.svg)](https://github.com/anc95/inquirer-file-tree-selection/actions/workflows/npm-publish.yml)

### QuickDemo
![QuickDemo](./example/screenshot.gif)

### Install
```sh
npm install inquirer-file-tree-selection-prompt
```

> If you are still using CJS, please install `inquirer-file-tree-selection-prompt@^1`

### Usage
```js
inquirer.registerPrompt('file-tree-selection', inquirerFileTreeSelection)

inquirer.prompt({
  type: 'file-tree-selection',
  ...
})
```

### Options
Takes `type`, `name`, `message`, [`filter`, `validate`, `transformer`, `default`, `pageSize`, `onlyShowDir`, `onlyShowValid`, `hideChildrenOfValid`, `root`, `hideRoot`, `multiple`, `enableGoUpperDirector`] properties.

The extra options that this plugin provides are:
- `onlyShowDir`:  (Boolean) if true, will only show directory. Default: false.
- `root`: (String) it is the root of file tree. Default: process.cwd(). 
- `onlyShowValid`: (Boolean) if true, will only show valid files (if `validate` is provided). Default: false.
- `hideChildrenOfValid`: (Boolean) if true, will hide children of valid directories (if `validate` is provided). Default: false.
- `transformer`: (Function) a hook function to transform the display of directory or file name.
- `multiple`: (Boolean) if true, will enable to select multiple files. Default: false.
- `enableGoUpperDirectory`: (Boolean) Show `..` in inside root dir, and the user can press **space** on it to go upper directory. Default: false.

When `multiple` is enabled, `default` should be `string[]` type, otherwise it's `string` type.
### Typescript Support

> version >= 1.0.16

1. Install `@types/inquirer`

2. Ensure you have registered with `file-tree-selection`

```js
inquirer.registerPrompt('file-tree-selection', inquirerFileTreeSelection)
```

3. And you will get type support when you code in IDE

![ts](./example/ts.jpeg)

### Example

ESM (version ^2)

```js
import inquirer from 'inquirer'
import inquirerFileTreeSelection from 'inquirer-file-tree-selection-prompt'

inquirer.registerPrompt('file-tree-selection', inquirerFileTreeSelection)

inquirer
  .prompt([
    {
      type: 'file-tree-selection',
      name: 'file'
    }
  ])
  .then(answers => {
    console.log(JSON.stringify(answers))
  });
```

CJS (version ^1 and <2)

```js
const inquirer = require('inquirer')
const inquirerFileTreeSelection = require('inquirer-file-tree-selection-prompt')

inquirer.registerPrompt('file-tree-selection', inquirerFileTreeSelection)

inquirer
  .prompt([
    {
      type: 'file-tree-selection',
      name: 'file'
    }
  ])
  .then(answers => {
    console.log(JSON.stringify(answers))
  });
```

[More examples](./example/)

---
_Source: https://npm.io/package/inquirer-file-tree-selection-prompt · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
