New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

daph

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

daph

✨ A simple CLI commander system

1.0.1
Source
npm
Version published
Weekly downloads
2
100%
Maintainers
1
Weekly downloads
 
Created
Source

🦄 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) // 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:
{
    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:
{
    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:
daph //         callback(commandName, args) ⬇️
    .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 ✨

Keywords

cli

FAQs

Package last updated on 22 Dec 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts