-
Notifications
You must be signed in to change notification settings - Fork 34
Write Useful Messages
It’s never too early to start thinking about the messages you display for your users. Messages include:
- Required summaries for every command and flag
- Optional longer descriptions for commands or flags
- Examples
- Error messages
- Interactive prompts
While you're free to write your messages in any style you want, we recommend that you follow these writing guidelines so that your commands feel similar to the core Salesforce CLI commands.
TBD. Bullet points:
- diff between
--helpand-h - markdown files in messages dir
- h1 for message name. List our conventions for naming (
summary,flags.<name>.summary, etc). Not necessary, but conventions are nice. - examples:
- to nicely render, use "-" for explanation and then indent with two spaces
- use
<%= config.bin %> <%= command.id %>
- errors:
- errors/warning/info messages are pre-pended at runtime with
Error:, etc. - Nice to have an action.
- errors/warning/info messages are pre-pended at runtime with
- package.json: topic descriptions
These writing guidelines ensure that the CLI messages for all commands are similar in style.
Use clear, concise descriptions so that users can easily understand what your commands do.
- Summaries start with an imperative verb.
- For example, a good summary for the
sf deploy metadatacommand isDeploy metadata to an org from your local project.
- For example, a good summary for the
- Summaries are mandatory for each command.
- The summary is the first message that displays when users run
--helpor-hfor a specific command. The summary is also displayed as the first sentence in the DESCRIPTION section when using--help. It's also the message that’s displayed when using--helpto list a group of commands. - Summaries include just enough information to tell users what the command helps them do, but are as short as possible.
- Summaries use proper punctuation and capitalization and are complete sentences.
- Command descriptions are optional but highly encouraged. They are displayed in the
--helpoutput, but not the-houtput. - Write them to expand on the summary, provide context about how and when a user runs the command, describe the behavior of the command, and provide other helpful information for the user. Here are some questions to help you pinpoint this other helpful information; not all questions are relevant to all commands.
- Where does this command fit in a typical developer workflow? Would it help the user to know which commands are typically run before or after?
- What, if any, are the repercussions of using this command? Is the command destructive? For example, does the command overwrite files in an org? Overwrite local files?
- Does the command behave unexpectedly when a user specifies a particular combination of flags?
- Is the command output easy to read, or is it complex enough that you should describe how to interpret it?
- Is there an operating system-specific gotcha? For example, do Windows users need to use quotes to enclose a value when macOS users don’t?
- Is there another command that the user might confuse with this one? Do you need to describe the use cases for each command?
- While there’s no theoretical limit to the length of a long description, try to keep it brief yet comprehensive.
- Long descriptions use proper punctuation and capitalization and are complete sentences.
Use clear, concise descriptions so that users can easily understand what the command flags do.
- Flag summaries are mandatory for each flag. They are displayed in tabular form in the top FLAGS section of both the
--helpand-houtput. - Flag summaries include just enough information to tell users what the flag does, but are as short as possible to minimize wrapping in narrow terminals.
- For flags that accept a value, the summary describes the value that the user supplies.
- For example, a good summary for the
--manifestflag of thesf deploy metadatacommand isFull file path for manifest (package.xml) of components to deploy.
- For example, a good summary for the
- For flags of type Boolean, which alter the behavior of a command but don't accept a value, the summary tells users what the flag makes the command do. Start these descriptions with an imperative verb.
- For example, the summary for the global
--jsonflag isFormat output as json.
- For example, the summary for the global
- Flag summaries use proper punctuation and capitalization and are complete sentences.
- Flag descriptions are optional. They are displayed in the FLAG DESCRIPTIONS section of the
--helpoutput. They aren't displayed in the-houtput. - Write flag descriptions to expand on the summary, provide context and other helpful information for the user.
- Don’t duplicate information in flag descriptions that’s in your command description.
- Flag descriptions use proper punctuation and capitalization and are complete sentences.
- There’s no limit to the length of a flag description, but remember that short is sweet.
Examples are the best way to help a user understand what a command does.
- Examples are optional, but highly encouraged. They are displayed in the EXAMPLES section of the
--helpoutput. They aren't displayed in the-houtput. - For each example, provide a brief explanation. If it's helpful, also provide the context in which it runs, and the expected outcome. Don’t show the actual output, just a brief description of what it should be.
- If you provide multiple examples, note how they differ and when to use one over another.
- Don’t duplicate information in examples that’s already in your description values.
- If necessary, provide any prerequisites to help users run their own examples. Warn users of any “gotchas” they might encounter.
- To keep the examples operating-system agnostic, use
<%= config.bin %> <%= command.id %>instead ofsf your-command. The CLI converts this string to the appropriate OS prompt and command name at runtime.
Mistakes happen. But on the bright side, they’re opportunities to expand our users' knowledge of the CLI by providing them an excellent error message.
- Use an error message to tell users how to recover from the situation that caused the error.
- Before writing an error message, find out whether the design can be changed to avoid the error.
- Tell users concisely, but also completely, what went wrong and what they can do about it. For example:
- Error message:
This command doesn't accept an access token for a username. - Action (aka “Try this:”):
Specify a username or an alias.
- Error message:
- Two short sentences are usually better than one long one. However, rather than first stating the problem and then the solution you can sometimes easily imply the problem in the solution. When possible, say what users can do instead of what they can’t.
- A good error message helps users move on rather than making them feel bad.
- Error messages use proper punctuation and capitalization and are complete sentences.
© 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