Skip to content

Commit

Permalink
fix: dynamic help (#395)
Browse files Browse the repository at this point in the history
* fix: dynamic help

* chore: update e2e tests
  • Loading branch information
mdonnalley authored Mar 31, 2022
1 parent 8ca7c9b commit 8ecc8f4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
14 changes: 1 addition & 13 deletions src/help/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import RootHelp from './root'
import {compact, sortBy, uniqBy} from '../util'
import {getHelpFlagAdditions, standardizeIDFromArgv} from './util'
import {HelpFormatter} from './formatter'
import {Plugin} from '../config/plugin'
import {toCached} from '../config/config'
export {CommandHelp} from './command'
export {standardizeIDFromArgv, loadHelpClass, getHelpFlagAdditions} from './util'
Expand Down Expand Up @@ -102,7 +101,7 @@ export class Help extends HelpBase {
const command = this.config.findCommand(subject)
if (command) {
if (command.hasDynamicHelp) {
const dynamicCommand = await toCached(await this.getDynamicCommand(command))
const dynamicCommand = await toCached(await command.load())
await this.showCommandHelp(dynamicCommand)
} else {
await this.showCommandHelp(command)
Expand All @@ -128,17 +127,6 @@ export class Help extends HelpBase {
error(`Command ${subject} not found.`)
}

private async getDynamicCommand(command: Interfaces.Command.Plugin): Promise<Interfaces.Command.Class> {
const plugin = new Plugin({ignoreManifest: true, root: this.config.root, name: command.pluginAlias ?? command.pluginName})
await plugin.load()
const cmd = await plugin.findCommand(command.id)
if (!cmd) {
throw new Error(`Command ${command.id} not found.`)
}

return cmd
}

public async showCommandHelp(command: Interfaces.Command) {
const name = command.id
const depth = name.split(':').length
Expand Down
2 changes: 1 addition & 1 deletion test/integration/sf.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ describe('Salesforce CLI (sf)', () => {
})

it('should handle varags', async () => {
const config = await executor.executeCommand('config set disableTelemetry=true restDeploy=true --global --json')
const config = await executor.executeCommand('config set disable-telemetry=true org-api-version=54.0 --global --json')
const parsed = parseJson(config.output!)
expect(parsed.status).to.equal(0)
const results = parsed.result as Array<{success: boolean}>
Expand Down

0 comments on commit 8ecc8f4

Please sign in to comment.