Skip to content

Commit

Permalink
Merge pull request #339 from salesforcecli/sm/use-option-flag
Browse files Browse the repository at this point in the history
refactor: use option flag
  • Loading branch information
mdonnalley authored Jan 23, 2024
2 parents dc2c88c + 43b2828 commit 6fbdbd5
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 459 deletions.
1 change: 0 additions & 1 deletion src/commands/apex/generate/trigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/


import {
arrayWithDeprecation,
Flags,
Expand Down
18 changes: 8 additions & 10 deletions src/commands/lightning/generate/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

// tslint:disable:no-unused-expression



import { Flags, loglevel, orgApiVersionFlagWithDeprecations, SfCommand, Ux } from '@salesforce/sf-plugins-core';
import { CreateOutput, LightningComponentOptions } from '@salesforce/templates';
import LightningComponentGenerator from '@salesforce/templates/lib/generators/lightningComponentGenerator.js';
Expand All @@ -35,22 +33,22 @@ export default class LightningComponent extends SfCommand<CreateOutput> {
aliases: ['componentname'],
deprecateAliases: true,
}),
template: Flags.string({
template: Flags.option({
char: 't',
summary: lightningCommon.getMessage('flags.template.summary'),
description: lightningCommon.getMessage('flags.template.description'),
default: 'default',
// Note: keep this list here and LightningComponentOptions#template in-sync with the
// templates/lightningcomponents/[aura|lwc]/* folders
options: ['default', 'analyticsDashboard', 'analyticsDashboardWithStep'],
}),
options: ['default', 'analyticsDashboard', 'analyticsDashboardWithStep'] as const,
})(),
'output-dir': outputDirFlagLightning,
'api-version': orgApiVersionFlagWithDeprecations,
type: Flags.string({
type: Flags.option({
summary: messages.getMessage('flags.type.summary'),
options: ['aura', 'lwc'],
options: ['aura', 'lwc'] as const,
default: 'aura',
}),
})(),
internal: internalFlag,
loglevel,
};
Expand All @@ -59,11 +57,11 @@ export default class LightningComponent extends SfCommand<CreateOutput> {
const { flags } = await this.parse(LightningComponent);
const flagsAsOptions: LightningComponentOptions = {
componentname: flags.name,
template: flags.template as 'default' | 'analyticsDashboard' | 'analyticsDashboardWithStep',
template: flags.template,
outputdir: flags['output-dir'],
apiversion: flags['api-version'],
internal: flags.internal,
type: flags.type as 'aura' | 'lwc',
type: flags.type,
};
return runGenerator({
generator: LightningComponentGenerator,
Expand Down
9 changes: 4 additions & 5 deletions src/commands/project/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/


import { Flags, loglevel, SfCommand, Ux } from '@salesforce/sf-plugins-core';
import { CreateOutput, ProjectOptions } from '@salesforce/templates';
import ProjectGenerator from '@salesforce/templates/lib/generators/projectGenerator.js';
Expand All @@ -30,13 +29,13 @@ export default class Project extends SfCommand<CreateOutput> {
aliases: ['projectname'],
deprecateAliases: true,
}),
template: Flags.string({
template: Flags.option({
char: 't',
summary: messages.getMessage('flags.template.summary'),
description: messages.getMessage('flags.template.description'),
default: 'standard',
options: ['standard', 'empty', 'analytics'],
}),
options: ['standard', 'empty', 'analytics'] as const,
})(),
'output-dir': outputDirFlag,
namespace: Flags.string({
char: 's',
Expand Down Expand Up @@ -79,7 +78,7 @@ export default class Project extends SfCommand<CreateOutput> {
outputdir: flags['output-dir'],
manifest: flags.manifest,
loginurl: flags['login-url'],
template: flags.template as 'standard' | 'empty' | 'analytics',
template: flags.template,
// namespace is a reserved keyword for the generator
ns: flags.namespace,
defaultpackagedir: flags['default-package-dir'],
Expand Down
Loading

0 comments on commit 6fbdbd5

Please sign in to comment.