package open

Not available on OCaml 5.5
  1. Overview
  2. Docs
Open files in their default applications

Install

dune-project
 Dependency

Authors

Maintainers

Sources

v0.2.2.tar.gz
sha256=2458a64a87437b87b2c195636bec1f811ceab176551db630fbad83af72fde13c
md5=b575f0e265a2877b2b6870b271961c55

Description

Added to opam-repository:

README

ocaml-open: open files in their default applications

Conveniently open files such as PDFs in their default applications straigt from OCaml.

Quick start

You can install the library using opam:

$ opam install open

Then in utop or ocaml,

$ ocaml
> #require "open";;
> Open.in_default_app "/home/steffen/ocaml.svg";;
- : bool = true
// SVG viewer opens and displays ocaml.svg
OCaml

The boolean returned by Open.in_default_app indicates whether the open command exited normally:

> Open.in_default_app "/path/to/non-existent.file";;
- : bool = false
// nothing happens

Both absolute and relative paths are supported:

> Open.in_default_app ".";;
- : bool = true
// file manager displays current working directory

API

The tiny API is documented here.

Building from source

Dependencies

The library requires dune (formerly known as jbuilder) to build, but has no other dependencies.

Building Library and Examples

Run make to build and make test to see the library in action. This should open several files from the examples/basic folder.

There is also a more sophisticated example in examples/graphviz that requires graphivz and Jane Street's core (version v0.9.0 or higher). You can build & run it as follows:

jbuilder build @graphviz

Limitations and Implementation

The library has been tested under Linux, MacOS, and Cygwin. There is experimental support for native Windows, but this is untested. The implementation uses

  • xdg-open on Linux
  • open on MacOS
  • cygstart on Cygiwn, and
  • cmd start on Windows.

Suggestion and Contributions

Suggestions and contributions are always welcome. Feel free to submit pull requests.

Dependencies (2)

  1. dune < "2.0"
  2. ocaml >= "4.02.3"

Dev Dependencies

None

Optional Dependencies

None

Conflicts

None

Build status

Results of building open with each compiler on check.ci.ocaml.org, run of against opam-repository 7cdc698. All results for this package.

Each result links to its build log. To keep crawlers from overloading the site, build logs require a GitHub sign-in (see ocurrent/opam-health-check). On your first log, GitHub asks you to “Authorize opam-health-check”, the OCurrent app that runs these checks; it sees only your public profile, not your repositories. The sign-in lasts 30 days.

Version OCaml 4.11 OCaml 4.14 OCaml 5.2 OCaml 5.4 OCaml 5.5
0.2.2 (this version) good n/a n/a n/a n/a
0.2.1 good good n/a n/a n/a
  • good Package successfully built
  • partial One of the dependencies failed to build
  • bad Package failed to build
  • n/a Package is not available in this environment
  • internal Internal failure