diff options
author | Teddy Wing | 2020-12-20 20:36:55 +0100 |
---|---|---|
committer | Teddy Wing | 2020-12-20 20:39:04 +0100 |
commit | 9a02b4d31ea4de91dbb11ad154231f9bda914318 (patch) | |
tree | 692ef7b8eb641224994d2de8e426bd397b15a939 | |
parent | 18033da5978da3d7c090d0e6e3d516d1b3c7ee19 (diff) | |
download | browserenv-9a02b4d31ea4de91dbb11ad154231f9bda914318.tar.bz2 |
Add README
Describe the package and include some examples.
-rw-r--r-- | README.md | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/README.md b/README.md new file mode 100644 index 0000000..608bdc7 --- /dev/null +++ b/README.md @@ -0,0 +1,56 @@ +browserenv +========== + +[](https://godoc.org/github.com/teddywing/browserenv) + +Browserenv allows URLs and files to be opened in a local web browser. It is a +drop-in replacement for the [`github.com/pkg/browser`][github.com/pkg/browser] +package. + +If the `BROWSER` environment variable is set, the input URL will be opened using +the command it defines rather than the system's default web browser. When +`BROWSER` is not defined, `github.com/pkg/browser` is used. + + +## Examples +Set `BROWSER` to a command that opens a URL. The URL is appended as an argument +to the command: + + BROWSER="open -a Firefox" + +If `%s` is included in the command, it is replaced with the URL: + + BROWSER="open -a Firefox '%s'" + +Multiple commands can be specified, delimited by colons. The commands will be +tried from left to right, stopping when a command exits with a 0 exit code. + + BROWSER="w3m '%s':open -a Firefox" + +A sample program: + +``` go +package main + +import ( + "strings" + + "github.com/teddywing/browserenv" +) + +func main() { + browserenv.OpenFile("file.gif") + + browserenv.OpenReader(strings.NewReader("Reader content")) + + browserenv.OpenURL("https://duckduckgo.com") +} +``` + + +## License +Copyright © 2020 Teddy Wing. Licensed under the Mozilla Public License v. 2.0 +(see the included LICENSE file). + + +[github.com/pkg/browser]: https://github.com/pkg/browser |