-
-
Save FabienTaillon/b35dd7f7ef277e096b6c5170b73cd8b1 to your computer and use it in GitHub Desktop.
old.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { flags, SfdxCommand } from '@salesforce/command'; | |
import { Messages, SfdxError } from '@salesforce/core'; | |
import { QueryResult, Record } from 'jsforce'; | |
// Initialize Messages with the current plugin directory | |
Messages.importMessagesDirectory(__dirname); | |
// Load the specific messages for this file. Messages from @salesforce/command, @salesforce/core, | |
// or any library that is using the messages framework can also be loaded this way. | |
const messages = Messages.loadMessages('texei-sfdx-plugin', 'command-old'); | |
export default class Enable extends SfdxCommand { | |
public static description = messages.getMessage('commandDescription'); | |
public static examples = [`sfdx texei:command:old --targetusername myOrg@example.com`]; | |
protected static flagsConfig = { | |
wait: flags.number({ char: 'w', description: messages.getMessage('waitFlagDescription'), required: false }), | |
}; | |
// 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 = true; | |
// Set this to true if your command requires a project workspace; 'requiresProject' is false by default | |
protected static requiresProject = true; | |
public async run(): Promise<any> { | |
this.ux.startSpinner('Starting command'); | |
const conn = this.org.getConnection(); | |
let orgName; | |
try { | |
const orgInfos: QueryResult<Record> = await conn.query('SELECT Name FROM Organization LIMIT 1'); | |
orgName = orgInfos.records[0].Name as string; | |
} catch (exception) { | |
throw new SfdxError('Something went wrong'); | |
} | |
this.ux.stopSpinner('Done.'); | |
const orgMessage = `Org Name: ${orgName}`; | |
this.ux.log(orgMessage); | |
return { message: orgMessage }; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment