# @cnamts/cli-helpers

> Helper functions to build CLI tools

Latest version **2.1.0** (published 2021-10-27) · MIT license · 0 weekly downloads

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

## Install

```sh
npm install @cnamts/cli-helpers
pnpm add @cnamts/cli-helpers
yarn add @cnamts/cli-helpers
bun add @cnamts/cli-helpers
```

## Health

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

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 2.1.0 |
| Published | 2021-10-27 |
| First published | 2019-06-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 18.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | CNAM |
| Maintainers | deraw, cnam-owner |
| Keywords | cnam, cli, typescript, helpers |

## Links

- npm: https://www.npmjs.com/package/@cnamts/cli-helpers
- Homepage: https://github.com/assurance-maladie-digital/design-system#readme
- Issues: https://github.com/assurance-maladie-digital/design-system/issues
- npm.io page: https://npm.io/package/@cnamts/cli-helpers

## Dependencies (2)

- [figlet](https://npm.io/package/figlet.md) ^1.3.0
- [@types/figlet](https://npm.io/package/@types/figlet.md) 1.5.4

## 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

- 2.1.0 (latest) — 2021-10-27
- 2.0.0-beta.12 (next) — 2021-08-02
- 2.0.0 — 2021-08-30
- 2.0.0-beta.10 — 2021-05-25
- 2.0.0-beta.8 — 2021-04-19
- 2.0.0-beta.4 — 2020-11-30
- 2.0.0-beta.3 — 2020-11-18
- 2.0.0-beta.2 — 2020-10-19
- 2.0.0-alpha.51 — 2020-06-02
- 2.0.0-alpha.48 — 2020-02-13
- 2.0.0-alpha.47 — 2020-01-29
- 2.0.0-alpha.46 — 2020-01-20
- 2.0.0-alpha.45 — 2020-01-09
- 2.0.0-alpha.44 — 2019-11-26
- 2.0.0-alpha.42 — 2019-11-21
- … 9 more at https://npm.io/package/@cnamts/cli-helpers/versions

## README

# CLI Helpers

> Helper functions to build CLI tools.

## Installation

This package is built with TypeScript and is meant to be used in TypeScript projects, but a JavaScript version is built so you can use it in node.js environment.

To install it, you need to use yarn or npm:

```sh
yarn add @cnamts/cli-helpers
# OR
npm install @cnamts/cli-helpers
```

## Usage

You can import the different helpers from the main file:

```ts
import { log, done, getPath } from '@cnamts/cli-helpers';
```

Or you can import them using their files, like so:

```ts
import { log, done } from '@cnamts/cli-helpers/src/logger';
import { getPath } from '@cnamts/cli-helpers/src/getPath';
```

## Helpers

### colors

Get an object with standardized colors.

```ts
import { colors } from '@cnamts/cli-helpers';

console.log(colors.primary); // Use 'primary' color
```

### getPath

Get path relative to current working directory.

```ts
import { getPath } from '@cnamts/cli-helpers';

const myPath = getPath('./file'); // Equivalent to path.join(process.cwd(), './file)
```

### traceLine

Trace a straight line across the terminal using box-drawing character `─`, by default it uses the `primary` color from [colors](./colors.ts), but you can change it.

```ts
import { traceLine } from '@cnamts/cli-helpers';

traceLine(); // Example: ───────────────────────

traceLine('#eee') // With custom color
```

### logger

Log informations to the user such as errors, warnings, events and others.

```ts
import { log, cmd, info, done, warn, error, verbose, event } from '@cnamts/cli-helpers';

log('Default log');
cmd('yarn lint');
info('Info log');
done('Success log');
warn('Warning log');
error('Error log');
verbose('Verbose log');
event('Event log');
```

![Result of different log methods in terminal](https://user-images.githubusercontent.com/10298932/69444239-3ec71280-0d50-11ea-83b4-46b1ecc69eaf.png)

### renderHeader

Display header with Georgia11 font and optionally author and/or version.

```ts
import { renderHeader } from '@cnamts/cli-helpers';

renderHeader('Package', 'Someone', '1.0.0');
```

![Result of renderHeader function in terminal](https://user-images.githubusercontent.com/10298932/69446366-851e7080-0d54-11ea-8c33-beb7e7e30c36.png)

## Contributing

Feel free to open an issue or a pull request to improve this package!
Just make sure to respect the code style by running `yarn lint` and to update the tests and check the coverage with `yarn test`.

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