I found myself wanting to provide some additional search terms to find one of my commands. My initial idea was to start putting those words in the description, but it ended up creating a really bad user experience with random words in the description that's displayed in the search results.
This PR adds the ability to add additional search terms (called synonyms here, but open to other ideas) to any command. This provides a simple way for developers to give their users additional terms to find commands.
For context, here's an example of how (and why) you might want to use synonyms for a command:
class ViewBillingSettings extends SpotlightCommand
{
protected string $name = 'View Billing Settings';
protected string $description = 'Update your billing settings';
protected array $synonyms = [
'subscription',
'credit card',
'payment',
];
public function execute(Spotlight $spotlight): void
{
$spotlight->redirect('/settings/billing');
}
}
This would allow for a user to type credit card and be show the View Billing Settings command in the search results.
I found myself wanting to provide some additional search terms to find one of my commands. My initial idea was to start putting those words in the description, but it ended up creating a really bad user experience with random words in the description that's displayed in the search results.
This PR adds the ability to add additional search terms (called synonyms here, but open to other ideas) to any command. This provides a simple way for developers to give their users additional terms to find commands.
For context, here's an example of how (and why) you might want to use synonyms for a command:
This would allow for a user to type
credit card
and be show the View Billing Settings command in the search results.