# face

> Build CLI apps with joy

Latest version **1.0.0** (published 2016-02-07) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install face
pnpm add face
yarn add face
bun add face
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2016-02-07 |
| First published | 2015-11-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 9 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Voyga |
| Maintainers | voyga |
| Keywords | cli, cliapp, terminal, console, command-line, shell, argv, parse |

## Links

- npm: https://www.npmjs.com/package/face
- Repository: https://github.com/voyga/face
- Homepage: https://github.com/voyga/face#readme
- Issues: https://github.com/voyga/face/issues
- npm.io page: https://npm.io/package/face

## Dependencies (9)

- [exit](https://npm.io/package/exit.md) ^0.1.2
- [perfume](https://npm.io/package/perfume.md) 0.0.11
- [minimist](https://npm.io/package/minimist.md) ^1.2.0
- [cli-clear](https://npm.io/package/cli-clear.md) ^1.0.4
- [exit-hook](https://npm.io/package/exit-hook.md) ^1.1.1
- [cli-cursor](https://npm.io/package/cli-cursor.md) ^1.0.2
- [window-size](https://npm.io/package/window-size.md) ^0.1.4
- [readline-sync](https://npm.io/package/readline-sync.md) ^1.2.22
- [update-notifier](https://npm.io/package/update-notifier.md) ^0.6.0

## Alternatives

- [@salesforce/cli](https://npm.io/package/@salesforce/cli.md) — 389.7K weekly downloads
- [@mintlify/cli](https://npm.io/package/@mintlify/cli.md) — 208.9K weekly downloads
- [@grafana/e2e-selectors](https://npm.io/package/@grafana/e2e-selectors.md) — 128.7K weekly downloads
- [mintlify](https://npm.io/package/mintlify.md) — 112.0K weekly downloads
- [@intlayer/cli](https://npm.io/package/@intlayer/cli.md) — 22.8K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2016-02-07
- 0.0.18 — 2016-01-20
- 0.0.17 — 2016-01-18
- 0.0.16 — 2016-01-18
- 0.0.15 — 2016-01-16
- 0.0.14 — 2016-01-16
- 0.0.13 — 2016-01-16
- 0.0.12 — 2016-01-15
- 0.0.11 — 2016-01-15
- 0.0.10 — 2016-01-15
- 0.0.9 — 2016-01-15
- 0.0.8 — 2015-12-08
- 0.0.7 — 2015-12-08
- 0.0.6 — 2015-12-02
- 0.0.5 — 2015-12-02
- … 4 more at https://npm.io/package/face/versions

## README

# Face
> Build CLI app with joy

## Install

```bash

$ npm install --save face

```

## Example

```javascript

const App = require("face");
const app = new App();

app.cmd("ask {{name}} {{question}}", (vars) => {

    app.println(`Hello (${vars.name}.):green`);

    app.ask(`(${vars.question}):blue `, (answer) => {

        app.println("Thanks!");

    });

}).help(() => {

    app.println("   Usage:", "bold");
    app.println("      (ask [name] [question]):blue to ask someone a question")

});

```

## API

#### app.argv
> The parsed user input. Using [minimist](https://github.com/substack/minimist)

#### app.cmd(template, callback)
> Execute the callback if the user inputs the template

###### Example

```javascript

app.cmd("ask {{name}} {{question}}", (vars) => {

    console.log(vars.name);
    console.log(vars.question);

});

```

#### app.opt(opts, callback)
> Execute the callback if the user inputs the option

###### Example

```javascript

app.opt(["w", "width"], (value) => {

    console.log(value);

});
```

#### app.help(callback)
> Execute the help function if the user inputs -h, --h or nothing

###### Example

```javascript

app.help(() => {

    console.log("Usage: ...");

});

```

#### app.print(string)
> Wrapper for process.stdout. Using [perfume](https://github.com/Voyga/perfume) to stylize output

###### Example

```javascript

app.print("Hello (World):red", "bold"); // apply `red` to 'World' and `bold` to the whole
app.print("(:joy:)"); // prints emoji

```

#### app.println(string)
> Wrapper for process.stdout. Using [perfume](https://github.com/Voyga/perfume) to stylize output

###### Example

```javascript

app.println("Hello (World):red", "bold"); // apply `red` to 'World' and `bold` to the whole
app.println("(:joy:)"); // prints emoji

```

#### app.ask(question, callback, options)
> Prompt for user input

###### Example

```javascript

app.ask("Username: ", (answer) => {

    console.log(`Your username is ${answer}`);

});

// Options

app.ask("Password: ", (answer) => {

    user.password = answer;

}, {

    hide: true, // hide the text
    mask: "*", // the mask shows instead of the hidden text
    default: "" // the default value

});

```

#### app.store(path, initVal)
> Use JSON to store data in `path`. Creates `app.storage` to manage data

###### Example

```javascript

app.store("user.json", {});
app.storage.data.name = "Voyga";
app.storage.save();

```

#### app.update(path)
> Execute the callback if there's an update. Using [update-notifier](https://github.com/yeoman/update-notifier)

###### Example

```javascript

app.update(require("./package.json"), () => {

    console.log("There's an update for this app!");

});

```

#### app.size
> The terminal window size

###### Example

```javascript

console.log(app.size.width);
console.log(app.size.height);

```

#### app.on(event, callback)
> Execute the callback on a certain event

###### Example

```javascript

// Current available events: `exit`, `key`

app.on("exit", () => {

    app.println("Exit");

}).on("key", (key) => {

    app.print(key);

});

```

#### app.cursor
> Hide and show the cursor. Using [cli-cursor](https://github.com/sindresorhus/cli-cursor)

###### Example

```javascript

app.cursor.hide();
app.cursor.show();

```

#### app.clearScreen()
> Clear the terminal screen

#### app.clearLine()
> Clear a line of output

#### app.exec(cmd, callback, options)
> Wrapper for `childProcess.exec`

#### app.exit(code)
> Wrapper for `process.exit`

#### All functions are chainable

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