hardis:org:connect
Description
Command Behavior
Connects to a Salesforce org without setting it as the default username, and optionally opens the org in a web browser.
This command provides a quick way to establish a connection to a Salesforce organization for one-off tasks or when you don't want to change your default org. It's useful for accessing different environments without disrupting your primary development setup.
Key functionalities:
- Org Selection: Prompts the user to select an existing Salesforce org or connect to a new one.
- Non-Default Connection: Ensures that the selected org is connected but does not set it as the default username for subsequent Salesforce CLI commands.
- Browser Launch (Optional): Offers to open the connected org directly in your default web browser, providing immediate access to the Salesforce UI.
Technical explanations
The command's technical implementation involves:
- Interactive Org Prompt: Uses the
promptOrgutility to display a list of available Salesforce orgs and allows the user to select one or initiate a new authentication flow. - Salesforce CLI Integration: Internally, it leverages Salesforce CLI commands to establish the connection to the chosen org. It does not use
sf config set target-orgto avoid changing the default org. - Browser Launch: If the user opts to open the org in a browser, it executes the
sf org opencommand, passing the selected org's username as the target. - Environment Awareness: Checks the
isCIflag to determine whether to offer the browser launch option, as it's typically not applicable in continuous integration environments.
Agent Mode
Supports --agent flag for automation detection:
sf hardis:org:connect --agent
In agent mode:
- This command is inherently interactive; an error is thrown recommending
sf org loginorsf org openinstead. - The browser open prompt is skipped.
Screenshots
Pick one of the authenticated orgs, or log in to another one
Connect to the Helios UAT sandbox without changing the default org, then open it in the browser
Parameters
| Name | Type | Description | Default | Required | Options |
|---|---|---|---|---|---|
| agent | boolean | Run in non-interactive mode for agents and automation | |||
| debug -d |
boolean | Activate debug mode (more logs) | |||
| flags-dir | option | Import flag values from a directory. | |||
| json | boolean | Format output as json. | |||
| skipauth | boolean | Skip authentication check when a default username is required | |||
| websocket | option | Websocket host:port for VsCode SFDX Hardis UI integration |
Examples
$ sf hardis:org:connect
$ sf hardis:org:connect --agent

