🦄 Daph
- A simple CLI commander system ✨
📥 Installation
Using yarn:
$ yarn add daph
Using npm:
$ npm install daph
🔧 Usage
daph
.createCommand(ICommand, callback(commandName, args) => unknown)
.createCommand(ICommand, callback(commandName, args) => unknown)
.help()
ICommand
: Where command is defined to be used when separating arguments. Structure:
{
name: "test",
usage: "--message <your_message>",
example: [ "--message Hello, world!", "-m Test message" ],
category: "test",
aliases: [ "t" ],
description: "just a test command",
argDefinitions: [
{ name: "message", type: String, aliases: [ "m" ] }
]
}
ArgDefinition
: Where options are defined to be used when separating arguments. Structure:
{
name: "message",
type: String
aliases?: [ "m" ],
default?: false,
isOptional?: false
}
callback(commandName, args) => unknown
: If the command you set is used, the action to be applied. Example:
daph.createCommand(ICommand, (commandName, args) => {
console.log("You used", commandName, "command with arguments", args);
});
🛠️ Example
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 ✨