Package mailcap is a port of the python3 mailcap library to golang and provides developers with the ability to query mimetypes and keys against the various mailcap files on a system to acquire an appropriate command to run in order to view, edit, etc a given file of a given mimetype.
Entry is a map of strings keyed with strings that represents a single mailcap entry. It represents one prgram for one mimetype. An entry can contain options for various keys (test, view, edit, etc).
Get the available actions/attributes for an entry as a string slice
Called on an Entry type that has an action set (either by calling SetAction on the Entry or by it being returned by FindMatch. Returns a pointer to type exec.Command and an error (or nil). The caller needs to remember to set Std in/out/err on the returned Cmd as is needed by their use case.
Retrieve the command string for a particular action. The string will not have a path inserted into it and will have %s to represent the place that the path will go. Returns a string and error (or nil).
Sets the action (key) for the entry calling it. This action is used when calling execute. The action is generally set by the Mailcap receiver FindMatch and SetAction is provided in order to easily manipulate an Entry found in the db directly. This is not recommended, but is provided as a lower level way of using the lib.
Mailcap is the main struct to interact with. It contains a Cap, as caps, that represents the full mailcap db for the system. It has a number of receivers to facilitate retrieving a command from a mimetype.
Creates and initializes the mailcap struct/db and returns a pointer to Mailcap struct
Retrieves an Entry for a given mimetype and key. Key is required to make sure the returned Entry has the capability that is desired. Common keys: "view", "edit". Also takes a bool, needsTerm, that can be set to true if the command must be executable in a terminal only environment.
Returns and Entry and an error
Returns Entry for a given mimetype and an error or nil.