Socket
Socket
Sign inDemoInstall

oclif

Package Overview
Dependencies
Maintainers
0
Versions
487
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

oclif

oclif: create your own CLI


Version published
Weekly downloads
140K
increased by11.87%
Maintainers
0
Weekly downloads
Β 
Created

What is oclif?

oclif is a framework for building command-line interfaces (CLIs) in Node.js. It provides a robust set of tools and conventions for creating and managing CLI applications, including support for plugins, argument parsing, and command scaffolding.

What are oclif's main functionalities?

Command Creation

This feature allows you to create new commands easily. The example demonstrates a simple 'Hello, world!' command.

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

class HelloWorldCommand extends Command {
  async run() {
    this.log('Hello, world!');
  }
}

HelloWorldCommand.run();

Argument Parsing

This feature provides built-in support for parsing command-line arguments and flags. The example shows a command that greets a user by name.

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

class GreetCommand extends Command {
  static flags = {
    name: flags.string({ char: 'n', description: 'name to print' })
  };

  async run() {
    const { flags } = this.parse(GreetCommand);
    this.log(`Hello, ${flags.name || 'world'}!`);
  }
}

GreetCommand.run();

Plugins

This feature allows you to extend your CLI with plugins. The example demonstrates loading plugins within a command.

const { Command } = require('@oclif/core');
const { Plugins } = require('@oclif/plugin-plugins');

class MyCommand extends Command {
  async run() {
    const plugins = new Plugins(this.config);
    await plugins.load();
    this.log('Plugins loaded');
  }
}

MyCommand.run();

Other packages similar to oclif

Keywords

FAQs

Package last updated on 07 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