Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

easy2command

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

easy2command

> :warning: Only for local use. Lack of basic security checks.

  • 1.0.6
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

Easy2Command

:warning: Only for local use. Lack of basic security checks.

A helper package for creating CLI applications using Commander.js and Inquirer.js.

Easy2Command makes it easy to load and execute commands from a directory of JavaScript files, and automatically creates an interactive menu for users to choose from.

Installation

npm install easy2command

Usage

Create a folder named 'commands' in your project, and add command files with a default exported class. Each command class should have a 'name', 'description', and a 'run' method. For example:

// commands/hello.js
class HelloCommand {
    constructor() {
        this.name = 'hello';
        this.description = 'Say hello';
    }

    async run() {
        console.log('Hello, world!');
    }
}

export default HelloCommand;

Then, in your main application file, import the CommandHelper package and use it like this:

import CommandHelper from 'commandhelper';

(async () => {
    const commandHelper = new CommandHelper();
    commandHelper.setCommandDir('./commands');
    await commandHelper.registerAllCommands();
    await commandHelper.displayInteractiveMenu();
})();

Now, when you run your application, CommandHelper will automatically load all commands from the 'commands' folder and display an interactive menu for users to choose from.

License

MIT

FAQs

Package last updated on 25 Apr 2023

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc