# oh-clif

> An objected oriented CLI framework built on top of yargs

Latest version **0.1.1-dev.0** (published 2021-08-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install oh-clif
pnpm add oh-clif
yarn add oh-clif
bun add oh-clif
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1-dev.0 |
| Published | 2021-08-22 |
| First published | 2021-08-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 3.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Joe McGuckin |
| Maintainers | joemcguckin14 |
| Keywords | object, oriented, cli, framework, oh, clif, cli |

## Links

- npm: https://www.npmjs.com/package/oh-clif
- Repository: https://github.com/joemcguckin14/oh-clif
- Homepage: https://github.com/joemcguckin14/oh-clif#readme
- Issues: https://github.com/joemcguckin14/oh-clif/issues
- npm.io page: https://npm.io/package/oh-clif

## Dependencies (1)

- [yargs](https://npm.io/package/yargs.md) ^17.1.1

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

- 0.1.1-dev.0 (latest) — 2021-08-22
- 0.1.1-dev.4 (dev) — 2021-08-23
- 0.1.1-dev.3 — 2021-08-23
- 0.1.1-dev.2 — 2021-08-23
- 0.1.1-dev.1 — 2021-08-23

## README

## Oh Clif!!

`oh-clif` is an object oriented cli framework intended for use with typescrypt (although it can also be used with pure javascript).

### Getting started

#### Install

```bash
# npm
npm i --save oh-clif

# yarn
yarn add oh-clif
```

#### Usage

First let's build a command

`MyCommand.ts`

```typescript
interface MyParams {
  message: string;
}

export default class MyCommand extends Command<MyParams> {
  // The key used to run your command
  get key(): string {
    return 'my-command';
  }

  get options(): Option[] {
    // Register all the options I can
    // pass to my command
    return [
      {
        name: 'message',
        attributes: {
          alias: 'm'
        }
      }
    ];
  }

  // What actually happens when i run
  // my command?
  async run(params: MyParams): Promise<void> {
    console.log(params?.message || 'No message');
  }
}
```

Now let's build a CLI

`MyCLI.ts`

```typescript
class MyCLI extends CLI {
  get commands(): Command<any>[] {
    // Register my command
    return [new MyCommand()];
  }
}
```

Now we just need to call the `init()` function in our entrypoint

`myScript.ts`

```typescript
#! /usr/bin/env node
new MyCLI().init();
```

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