Alfred v0.3.1 Alfred.Result View Source

Represents a result to be displayed in an Alfred search list.

Every result is required to have a title and a subtitle. Beyond this, there are many optional attributes that are helpful in various scenarios:

  • :arg (recommended) — Text that is passed to connected output actions in workflows
  • :autocomplete (recommended) — Text which is populated into Alfred's search field if the user autocompletes the result
  • :quicklookurl — URL which will be visible if the user uses the Quick Look feature
  • :uid — Used to track an item across invocations so that Alfred can do its frecency sorting
  • :valid — When false it means that the result cannot be selected

See: Script Filter JSON Format

Link to this section Summary

Functions

Creates a new generic result

Creates a new URL result

Converts the results to the expected JSON output format

Link to this section Types

Link to this type t() View Source
t() :: %Alfred.Result{arg: String.t(), autocomplete: String.t(), quicklookurl: String.t(), subtitle: String.t(), title: String.t(), uid: String.t(), valid: boolean()}

Link to this section Functions

Link to this function new(title, subtitle, options \\ []) View Source
new(String.t(), String.t(), Keyword.t()) :: t()

Creates a new generic result.

Examples

Basic result:

iex> Alfred.Result.new("title", "subtitle")
%Alfred.Result{subtitle: "subtitle", title: "title"}

Result with some optional attributes:

iex> Alfred.Result.new("title", "subtitle", arg: "output", valid: false, uid: "test")
%Alfred.Result{arg: "output", subtitle: "subtitle", title: "title", uid: "test", valid: false}
Link to this function new_url(title, url) View Source
new_url(String.t(), String.t()) :: t()

Creates a new URL result.

Examples

Basic URL result:

iex> Alfred.Result.new_url("title", "http://www.example.com")
%Alfred.Result{arg: "http://www.example.com", autocomplete: "title",
quicklookurl: "http://www.example.com", subtitle: "http://www.example.com", title: "title",
uid: "http://www.example.com", valid: nil}
Link to this function to_json(results) View Source
to_json(t()) :: String.t()

Converts the results to the expected JSON output format.