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

clipanion

Package Overview
Dependencies
Maintainers
1
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clipanion

  • 2.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2M
decreased by-3.84%
Maintainers
1
Weekly downloads
 
Created

What is clipanion?

The clipanion npm package is a powerful library for building command-line interfaces (CLIs) in Node.js. It provides a rich set of features for defining commands, parsing arguments, validating input, and generating help messages.

What are clipanion's main functionalities?

Command Definition

Clipanion allows you to define commands as classes, which can then be registered with a CLI instance. Each command can have its own execute method that contains the logic to be run when the command is invoked.

class MyCommand extends Command {
  execute() {
    console.log('Command executed!');
  }
}

const cli = new Cli();
cli.register(MyCommand);
cli.runExit(process.argv.slice(2));

Argument Parsing

Clipanion provides a declarative way to define command arguments using class properties. These arguments are automatically parsed and made available within the command's execute method.

class MyCommand extends Command {
  myArgument = Option.String();

  execute() {
    console.log(`Argument value: ${this.myArgument}`);
  }
}

const cli = new Cli();
cli.register(MyCommand);
cli.runExit(process.argv.slice(2));

Input Validation

Clipanion includes built-in validation for command arguments. You can specify whether an argument is required, and Clipanion will automatically enforce this when the command is run.

class MyCommand extends Command {
  myArgument = Option.String({ required: true });

  execute() {
    console.log(`Argument value: ${this.myArgument}`);
  }
}

const cli = new Cli();
cli.register(MyCommand);
cli.runExit(process.argv.slice(2));

Help Generation

Clipanion can automatically generate help messages for your commands. You can provide descriptions, detailed information, and usage examples that will be displayed when the help command is invoked.

class MyCommand extends Command {
  static usage = Command.Usage({
    description: 'My command description',
    details: 'Detailed information about my command',
    examples: [['Example usage', 'my-cli my-command']]
  });

  execute() {
    console.log('Command executed!');
  }
}

const cli = new Cli();
cli.register(MyCommand);
cli.runExit(process.argv.slice(2));

Other packages similar to clipanion

FAQs

Package last updated on 21 Aug 2019

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