How to use @salesforce/command - 10 common examples

To help you get started, we’ve selected a few @salesforce/command examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wadewegner / sfdx-waw-plugin / src / commands / waw / connectedapp / create.ts View on Github external
description: messages.getMessage('connectedapp.create.flags.certificate')
    }),
    callbackurl: flags.string({
      char: 'c',
      description: messages.getMessage('connectedapp.create.flags.callbackurl')
    }),
    description: flags.string({
      char: 'd',
      description: messages.getMessage('connectedapp.create.flags.description')
    }),
    scopes: flags.string({
      // Basic,Api,Web,Full,Chatter,CustomApplications,RefreshToken,OpenID,CustomPermissions,Wave,Eclair
      char: 's',
      description: messages.getMessage('connectedapp.create.flags.scopes')
    }),
    contactemail: flags.string({
      char: 'e',
      description: messages.getMessage('connectedapp.create.flags.contactemail')
    })
  };

  protected static requiresUsername = true;

  public async run(): Promise {
    const username = this.org.getUsername();
    const fullName = this.flags.name;
    const label = this.flags.label || fullName;
    const contactEmail = this.flags.contactemail || username;
    const callbackUrl = this.flags.callbackurl || 'sfdx://success';
    const createCerts = this.flags.certificate;
    const description = this.flags.description || 'generated by waw:connectedapp:create';
    const scopes = this.flags.scopes && this.flags.scopes.split(',') || ['Basic', 'Api', 'Web', 'RefreshToken'];
github stomita / sfdx-migration-automatic / src / commands / automig / dump.ts View on Github external
char: 'f',
      description: messages.getMessage('configFlagDescription')
    }),
    objects: flags.array({
      char: 'o',
      description: messages.getMessage('objectsFlagDescription'),
      map: (value: string) => {
        const [ object, target = 'query' ] = value.split(':');
        return { object, target };
      }
    }),
    outputdir: flags.directory({
      char: 'd',
      description: messages.getMessage('outputDirFlagDescription')
    }),
    excludebom: flags.boolean({
      description: messages.getMessage('excludeBomFlagDescription')
    })
  };

  // Comment this out if your command does not require an org username
  protected static requiresUsername = true;

  // Comment this out if your command does not support a hub org username
  protected static supportsDevhubUsername = false;

  // Set this to true if your command requires a project workspace; 'requiresProject' is false by default
  protected static requiresProject = false;

  public async run(): Promise {
    // const name = this.flags.name || 'world';
github stomita / sfdx-migration-automatic / src / commands / automig / load.ts View on Github external
protected static flagsConfig = {
    // flag with a value (-n, --name=VALUE)
    inputdir: flags.directory({
      char: 'd',
      description: messages.getMessage('inputDirFlagDescription'),
      required: true
    }),
    mappingobjects: flags.array({
      char: 'm',
      description: messages.getMessage('mappingObjectsFlagDescription'),
      map: (value: string) => {
        const [ object, keyField = 'Name' ] = value.split(':');
        return { object, keyField };
      }
    }),
    deletebeforeload: flags.boolean({
      description: messages.getMessage('deleteBeforeLoadFlagDescription')
    }),
    verbose: flags.builtin()
  };

  // Comment this out if your command does not require an org username
  protected static requiresUsername = true;

  // Comment this out if your command does not support a hub org username
  protected static supportsDevhubUsername = false;

  // Set this to true if your command requires a project workspace; 'requiresProject' is false by default
  protected static requiresProject = false;

  /**
   *
github amtrack / sfdx-browserforce-plugin / src / browserforceCommand.ts View on Github external
public async init() {
    await super.init();
    const definition = await core.fs.readJson(
      path.resolve(this.flags.definitionfile)
    );
    // TODO: use require.resolve to dynamically load plugins from npm packages
    this.settings = ConfigParser.parse(DRIVERS, definition);
    this.bf = new Browserforce(this.org, this.ux.cli);
    this.ux.startSpinner('logging in');
    await this.bf.login();
    this.ux.stopSpinner();
  }
github stomita / sfdx-migration-automatic / src / commands / automig / dump.ts View on Github external
public static get usage() {
    return SfdxCommand.usage.replace('<%= command.id %>', 'automig:dump');
  }

  public static examples = [
  '$ sfdx automig:dump --targetusername username@example.com --objects Opportunity,Case,Account:related,Task:related --outputdir ./dump',
  '$ sfdx automig:dump --targetusername username@example.com --config automig-dump-config.json'
  ];

  protected static flagsConfig = {
    // flag with a value (-n, --name=VALUE)
    config: flags.filepath({
      char: 'f',
      description: messages.getMessage('configFlagDescription')
    }),
    objects: flags.array({
      char: 'o',
      description: messages.getMessage('objectsFlagDescription'),
      map: (value: string) => {
        const [ object, target = 'query' ] = value.split(':');
        return { object, target };
      }
    }),
    outputdir: flags.directory({
      char: 'd',
      description: messages.getMessage('outputDirFlagDescription')
    }),
    excludebom: flags.boolean({
      description: messages.getMessage('excludeBomFlagDescription')
    })
  };
github stomita / sfdx-migration-automatic / src / commands / automig / load.ts View on Github external
return SfdxCommand.usage.replace('<%= command.id %>', 'automig:load');
  }

  public static examples = [
  '$ sfdx automig:load --targetusername username@example.com --inputdir ./data',
  '$ sfdx automig:load --targetusername username@example.com --inputdir ./data --mappingobjects User:Email,RecordType:DeveloperName'
  ];

  protected static flagsConfig = {
    // flag with a value (-n, --name=VALUE)
    inputdir: flags.directory({
      char: 'd',
      description: messages.getMessage('inputDirFlagDescription'),
      required: true
    }),
    mappingobjects: flags.array({
      char: 'm',
      description: messages.getMessage('mappingObjectsFlagDescription'),
      map: (value: string) => {
        const [ object, keyField = 'Name' ] = value.split(':');
        return { object, keyField };
      }
    }),
    deletebeforeload: flags.boolean({
      description: messages.getMessage('deleteBeforeLoadFlagDescription')
    }),
    verbose: flags.builtin()
  };

  // Comment this out if your command does not require an org username
  protected static requiresUsername = true;
github stomita / sfdx-migration-automatic / src / commands / automig / load.ts View on Github external
char: 'd',
      description: messages.getMessage('inputDirFlagDescription'),
      required: true
    }),
    mappingobjects: flags.array({
      char: 'm',
      description: messages.getMessage('mappingObjectsFlagDescription'),
      map: (value: string) => {
        const [ object, keyField = 'Name' ] = value.split(':');
        return { object, keyField };
      }
    }),
    deletebeforeload: flags.boolean({
      description: messages.getMessage('deleteBeforeLoadFlagDescription')
    }),
    verbose: flags.builtin()
  };

  // Comment this out if your command does not require an org username
  protected static requiresUsername = true;

  // Comment this out if your command does not support a hub org username
  protected static supportsDevhubUsername = false;

  // Set this to true if your command requires a project workspace; 'requiresProject' is false by default
  protected static requiresProject = false;

  /**
   *
   */
  public async run(): Promise {
    const inputDir = this.flags.inputdir;
github stomita / sfdx-migration-automatic / src / commands / automig / dump.ts View on Github external
protected static flagsConfig = {
    // flag with a value (-n, --name=VALUE)
    config: flags.filepath({
      char: 'f',
      description: messages.getMessage('configFlagDescription')
    }),
    objects: flags.array({
      char: 'o',
      description: messages.getMessage('objectsFlagDescription'),
      map: (value: string) => {
        const [ object, target = 'query' ] = value.split(':');
        return { object, target };
      }
    }),
    outputdir: flags.directory({
      char: 'd',
      description: messages.getMessage('outputDirFlagDescription')
    }),
    excludebom: flags.boolean({
      description: messages.getMessage('excludeBomFlagDescription')
    })
  };

  // Comment this out if your command does not require an org username
  protected static requiresUsername = true;

  // Comment this out if your command does not support a hub org username
  protected static supportsDevhubUsername = false;

  // Set this to true if your command requires a project workspace; 'requiresProject' is false by default
  protected static requiresProject = false;
github stomita / sfdx-migration-automatic / src / commands / automig / load.ts View on Github external
export default class Load extends SfdxCommand {

  public static description = messages.getMessage('commandDescription');

  public static get usage() {
    return SfdxCommand.usage.replace('<%= command.id %>', 'automig:load');
  }

  public static examples = [
  '$ sfdx automig:load --targetusername username@example.com --inputdir ./data',
  '$ sfdx automig:load --targetusername username@example.com --inputdir ./data --mappingobjects User:Email,RecordType:DeveloperName'
  ];

  protected static flagsConfig = {
    // flag with a value (-n, --name=VALUE)
    inputdir: flags.directory({
      char: 'd',
      description: messages.getMessage('inputDirFlagDescription'),
      required: true
    }),
    mappingobjects: flags.array({
      char: 'm',
      description: messages.getMessage('mappingObjectsFlagDescription'),
      map: (value: string) => {
        const [ object, keyField = 'Name' ] = value.split(':');
        return { object, keyField };
      }
    }),
    deletebeforeload: flags.boolean({
      description: messages.getMessage('deleteBeforeLoadFlagDescription')
    }),
    verbose: flags.builtin()
github stomita / sfdx-migration-automatic / src / commands / automig / dump.ts View on Github external
export default class Dump extends SfdxCommand {

  public static description = messages.getMessage('commandDescription');

  public static get usage() {
    return SfdxCommand.usage.replace('<%= command.id %>', 'automig:dump');
  }

  public static examples = [
  '$ sfdx automig:dump --targetusername username@example.com --objects Opportunity,Case,Account:related,Task:related --outputdir ./dump',
  '$ sfdx automig:dump --targetusername username@example.com --config automig-dump-config.json'
  ];

  protected static flagsConfig = {
    // flag with a value (-n, --name=VALUE)
    config: flags.filepath({
      char: 'f',
      description: messages.getMessage('configFlagDescription')
    }),
    objects: flags.array({
      char: 'o',
      description: messages.getMessage('objectsFlagDescription'),
      map: (value: string) => {
        const [ object, target = 'query' ] = value.split(':');
        return { object, target };
      }
    }),
    outputdir: flags.directory({
      char: 'd',
      description: messages.getMessage('outputDirFlagDescription')
    }),
    excludebom: flags.boolean({