Socket
Socket
Sign inDemoInstall

@oclif/core

Package Overview
Dependencies
Maintainers
0
Versions
396
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@oclif/core

base library for oclif CLIs


Version published
Maintainers
0
Created

What is @oclif/core?

The @oclif/core npm package is a framework for building command-line interfaces (CLIs) in Node.js. It provides a powerful set of tools to develop sophisticated CLIs with features such as argument parsing, command structure, and plugin support. This package is part of the Open CLI Framework (OCLIF) developed by Heroku.

What are @oclif/core's main functionalities?

Command Creation

This feature allows developers to create custom commands for their CLI. The code sample demonstrates how to define a simple command that accepts a name as a flag and prints a greeting message.

const {Command, flags} = require('@oclif/core');

class MyCommand extends Command {
  async run() {
    const {flags} = await this.parse(MyCommand);
    console.log(`Hello, ${flags.name}!`);
  }
}

MyCommand.description = 'Describe the command here';

MyCommand.flags = {
  name: flags.string({char: 'n', description: 'name to print'}),
};

module.exports = MyCommand;

Argument Parsing

This feature simplifies the process of parsing arguments passed to commands. The code sample shows how to create a command that echoes a message passed as an argument.

const {Command, flags} = require('@oclif/core');

class EchoCommand extends Command {
  async run() {
    const {args} = await this.parse(EchoCommand);
    console.log(`Echoing: ${args.message}`);
  }
}

EchoCommand.args = [{name: 'message'}];

module.exports = EchoCommand;

Plugin Support

OCLIF supports plugins to extend the functionality of your CLI. This code sample demonstrates how to define a simple plugin that includes a custom command.

const {Command, Plugin} = require('@oclif/core');

class MyPlugin extends Plugin {
  constructor(root, config) {
    super(root, config);
    this.name = 'my-plugin';
  }

  commands = [require('./commands/my-command')];
}

module.exports = MyPlugin;

Other packages similar to @oclif/core

Keywords

FAQs

Package last updated on 01 Jul 2024

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