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

@salesforce/command

Package Overview
Dependencies
Maintainers
54
Versions
124
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@salesforce/command

Salesforce CLI base command class

  • 5.3.9
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
54
Created

What is @salesforce/command?

@salesforce/command is an npm package that provides a framework for building CLI commands for Salesforce. It is designed to help developers create commands that interact with Salesforce APIs and services, making it easier to automate tasks and integrate Salesforce with other systems.

What are @salesforce/command's main functionalities?

Command Creation

This feature allows developers to create custom CLI commands by extending the SfdxCommand class. The example demonstrates a simple command that logs a message to the console.

const { SfdxCommand } = require('@salesforce/command');

class MyCommand extends SfdxCommand {
  async run() {
    this.ux.log('Hello, Salesforce!');
  }
}

module.exports = MyCommand;

Parameter Handling

This feature provides a way to define and handle command-line parameters using the flags property. The example shows how to define a 'name' parameter and use it within the command.

const { flags, SfdxCommand } = require('@salesforce/command');

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

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

module.exports = MyCommand;

Salesforce Authentication

This feature allows commands to authenticate and interact with Salesforce orgs. The example demonstrates how to create a connection and query Salesforce data.

const { SfdxCommand } = require('@salesforce/command');
const { Connection } = require('@salesforce/core');

class MyCommand extends SfdxCommand {
  async run() {
    const conn = await Connection.create({ authInfo: this.org.getConnection().getAuthInfo() });
    const result = await conn.query('SELECT Id, Name FROM Account');
    this.ux.logJson(result.records);
  }
}

module.exports = MyCommand;

Other packages similar to @salesforce/command

Keywords

FAQs

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