A port of the Python3 mailcap library to Go
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
sloumdrone b787a49e9d Removes unnecessary types and reworks execute method to return an exec.Cmd pointer 3 years ago
README.md Adds godoc badge to readme 3 years ago
go.mod Ready to test building of db, pushing to remote 3 years ago
mailcap.go Removes unnecessary types and reworks execute method to return an exec.Cmd pointer 3 years ago

README.md

Mailcap

GoDoc

Golang port of the Python3 mailcap library.

Usage

An eaxmple showing how to launch a program based on its mime/media type:

import(
    tildegit.org/sloum/mailcap
)

func main() {
  // Build the mailcap database
  mc := mailcap.NewMailcap()

  // Find an avialable command with the required key and gui avialability
  command, err := mc.FindMatch("text/csv", "edit", false)
  if err != nil {
    panic(err)
  }

  // Run the command with the filepath provided
  err := command.Execute("/var/www/data/some_data.csv")
  if err != nil {
    panic(err)
  }

  // Now that the user has been presented the file to edit,
  // something can be done with the updated file...
}

In general usage a user will build the mailcap db, find a match, and execute the command they find with a certain filepath.

A few other helper methods are available for debugging or lower level mailcap work.