kevinohara80/dmc

Move org loader to module and execute inside of run() functions

Opened this issue · 0 comments

The reason why each command module exports separate run() and cli() functions is so that the run() function can be easily consumed by a non-cli application. Currently, the cli manages taking an org argument and using it to resolve the proper stored oauth data and passed that oauth data into the run function as an options property.

Therefore, if a non-cli application is consuming the run() method, it must provide the oauth data and can't take advantage of the internal oauth/login management of dmc.

I propose that we move this org loading logic to a module that is called within each run() method for commands that require Salesforce communication. I think the api for the run method should support either (a) the org argument, (b) the oauth argument, or (c) neither that results in falling back to default orgs in the configuration. The loader would handle the negotiation of the arguments to figure out how to return the required oauth.