sfdx-hardis
Version:
Swiss-army-knife Toolbox for Salesforce. Allows you to define a complete CD/CD Pipeline. Orchestrate base commands and assist users with interactive wizards
48 lines (41 loc) • 1.81 kB
JavaScript
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
import { Messages } from '@salesforce/core';
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
const messages = Messages.loadMessages('sfdx-hardis', 'hello.world');
export default class World extends SfCommand {
static summary = messages.getMessage('summary');
static description = `
## Command Behavior
**Says hello to the world or a specified person.**
This is a simple command used for demonstration purposes. It outputs a greeting message to the console.
Key functionalities:
- **Customizable Greeting:** You can specify a name using the \`--name\` flag to personalize the greeting.
- **Timestamp:** The greeting includes the current date.
<details markdown="1">
<summary>Technical explanations</summary>
The command's technical implementation involves:
- **Flag Parsing:** It parses the \`--name\` flag to get the recipient of the greeting.
- **Date Retrieval:** It gets the current date using \`new Date().toDateString()\`.
- **Console Output:** It constructs the greeting message using the provided name and the current date, and then logs it to the console using \`this.log()\`.
</details>
`;
static examples = messages.getMessages('examples');
static flags = {
name: Flags.string({
char: 'n',
summary: messages.getMessage('flags.name.summary'),
description: messages.getMessage('flags.name.description'),
default: 'World',
}),
};
async run() {
const { flags } = await this.parse(World);
const time = new Date().toDateString();
this.log(messages.getMessage('info.hello', [flags.name, time]));
return {
name: flags.name,
time,
};
}
}
//# sourceMappingURL=world.js.map