# daph

> ✨ A simple CLI commander system

Latest version **1.0.2** (published 2022-07-24) · GPL-3.0 license · 0 weekly downloads

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

## Install

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

## Health

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

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2022-07-24 |
| First published | 2020-11-24 |
| Weekly downloads | 0 |
| License | GPL-3.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 65 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Barış DEMİRCİ |
| Maintainers | leydihavuc |
| Keywords | cli, commander, cli-commander, command-line-interface, command-line, args, arg, argument, parser, parse, argv, parsing, argument-parser, arguments, argv-parser |

## Links

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

## Dependencies (2)

- [bargs](https://npm.io/package/bargs.md) ^1.0.4
- [colors](https://npm.io/package/colors.md) ^1.4.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.2 (latest) — 2022-07-24
- 1.0.1 — 2020-12-22
- 1.0.0 — 2020-11-24

## README

# 🦄 Daph

-   A simple CLI commander system ✨

# 📥 Installation

Using yarn:

```
$ yarn add daph
```

Using npm:

```
$ npm install daph
```

# 🔧 Usage

```ts
daph
    .createCommand(ICommand, callback(commandName, args) => unknown) // create command
    .createCommand(ICommand, callback(commandName, args) => unknown) // create another command
    .help() // If none of the above commands are used, execute the help command.
```

-   `ICommand`: Where command is defined to be used when separating arguments. Structure:

```js
{
    name: "test", // Command name
    usage: "--message <your_message>", // Command usage
    example: [ "--message Hello, world!", "-m Test message" ], // Usage examples
    category: "test", // Command category
    aliases: [ "t" ], // Command aliases
    description: "just a test command", // Command description
    argDefinitions: [
        { name: "message", type: String, aliases: [ "m" ] }
    ] // Arg definition array (Learn about ArgDefinition below)
}
```

-   `ArgDefinition`: Where options are defined to be used when separating arguments. Structure:

```js
{
    name: "message", // Option name
    type: String // Option type (function)
    aliases?: [ "m" ], // Option aliases (optional)
    default?: false, // optional
    isOptional?: false // optional
}
```

-   `callback(commandName, args) => unknown`: If the command you set is used, the action to be applied. Example:

```js
daph.createCommand(ICommand, (commandName, args) => { //         callback(commandName, args) ⬇️
    console.log("You used", commandName, "command with arguments", args);
});
```

# 🛠️ Example

```js
import daph from "daph";

daph
    .createCommand({
        name: "install",
        usage: "<module_name> [--version] <package_version>",
        example: [ "daph", "bargs --version 1.0.1" ],
        category: "utility",
        aliases: [ "i", "add" ],
        description: "Install packages from server",
        argDefinitions: [
            { name: "module", type: String, default: true },
            { name: "version", type: String, isOptional: true }
        ]
    }, (commandName, args) => {
        const { module, version } = args;
        console.log("You have downloaded package", module, "with version" version ? version : "latest");
    })
    .help()
```

# 🔗 Contributing / Issues / Ideas

Feel free to use GitHub's features ✨

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