A port of the Python3 mailcap library to Go
Go to file
sloumdrone 27261a6f6c Updates package comments 2019-07-03 14:39:38 -07:00
README.md Adds readme example and fixes logical error in execute 2019-07-03 12:30:49 -07:00
go.mod Ready to test building of db, pushing to remote 2019-06-27 21:13:55 -07:00
mailcap.go Updates package comments 2019-07-03 14:39:38 -07:00

README.md

Mailcap

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/plain", "edit", false)
  if err != nil {
    panic(err)
  }

  // Run the command with the filepath provided
  err := command.Execute("/var/www/index.html")
  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.