A port of the Python3 mailcap library to Go
Go to file
sloumdrone b787a49e9d Removes unnecessary types and reworks execute method to return an exec.Cmd pointer 2019-07-06 14:40:29 -07:00
README.md Adds godoc badge to readme 2019-07-04 16:19:46 -07:00
go.mod Ready to test building of db, pushing to remote 2019-06-27 21:13:55 -07:00
mailcap.go Removes unnecessary types and reworks execute method to return an exec.Cmd pointer 2019-07-06 14:40:29 -07:00

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.