-
Notifications
You must be signed in to change notification settings - Fork 21
Design Guidelines Interactivity
Interactive commands are a powerful way to develop a great experience for your users. Our goal is to make Salesforce CLI approachable to all users, and interactivity helps make this possible. Keep these general guidelines in mind when implementing interactive prompts.
We recommend that you ask as few questions as possible so as to not overwhelm your users. Asking users dozens of questions all at once can cause decision fatigue and lead to a poor experience. Instead, ask the most meaningful and necessary questions to gather the information you need.
Many Salesforce CLI users leverage the --json
flag to write scripts for their continuous integration (CI) environments. These users often load the JSON response into a JSON parsing utility like jq
. As a result, the JSON output in stdout must be parsable or else these users' scripts fail.
If you implement a prompt on a command that supports --json
, the resulting JSON isn't parsable because the prompts are part of the stdout.
We recommend one of the following:
-
Develop commands that are either interactive or scriptable (support
--json
), but not both. In other words, if you plan for a command to be interactive, then disable the--json
flag by settingenableJsonFlag = false
on the command class that extendsSfCommand
. -
If you require a command that is both interactive and scriptable, then add flags that supply the same information gathered by the interactive prompt. You must use
this.jsonEnabled
before starting the prompt so that you don't accidentally prompt the user when they provide the--json
flag.
© Copyright 2024 Salesforce.com, inc. All rights reserved. Various trademarks held by their respective owners.
- Quick Intro to Developing sf Plugins
- Get Started: Create Your First Plugin
- Design Guidelines
- Code Your Plugin
- Debug Your Plugin
- Write Useful Messages
- Test Your Plugin
- Maintain Your Plugin
- Integrate Your Plugin With the Doctor Command
- Migrate Plugins Built for sfdx
- Conceptual Overview of Salesforce CLI