oclif / core

Node.js Open CLI Framework. Built by Salesforce.

Home Page:https://oclif.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

improve topic help resolution if `@oclif/plugin-help` isn't available as a plugin

cristiand391 opened this issue · comments

Is your feature request related to a problem? Please describe.
when running typing <cli> <topic> without having @oclif/plugin-help as a plugin/devPlugin oclif fails to get topic help text and renders and instead throws Error: command help not found:

➜  sf-plugin-api git:(main) ./bin/dev org
Error: command help not found
    at Config.runCommand (/Users/cdominguez/code/gh/sf-plugin-api/node_modules/@oclif/core/lib/config/config.js:284:19)
➜  sf-plugin-api git:(main) ./bin/run org
 ›   Error: command help not found

Examples using this plugin: https://github.com/cristiand391/sf-plugin-api/

this is caused by core trying to run help <topic> when id is a valid topic:

if (topic) return config.runCommand('help', [id])

example:
./bin/dev org -> id = org
org is a valid topic in my plugin so it tries to run help org to render the help text.

Workaround

use --help so that core loads the helpclass without the help command:

if (helpAddition(argv, config)) {

Describe the solution you'd like
IMO, CLI plugins shouldn't be required to bring in @oclif/plugin-help as a devDependency. What if core just loads the helpclass instead of calling help.
If that's not possible, maybe the command help not found could be improved.

Describe alternatives you've considered
--help works.

Additional context
Found by Rupert Barrow 😉 , just wanted to file an issue with what I found while trying to get and answer for him:
https://trailhead.salesforce.com/trailblazer-community/feed/0D54V00007OYgsj

This issue has been linked to a new work item: W-15103728