npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@enspirit/bs-cmdliner

v0.1.1

Published

Cmdliner — Declarative definition of command line interfaces for OCaml

Downloads

1

Readme

bs-cmdliner

This is Cmdliner, a CLI-interface building tool for OCaml, packaged for BuckleScript (an OCaml-to-JavaScript compiler) and Reason (an alternative OCaml syntax targeting that compiler.)

IMPORTANT: this is a fork of the bindings by ELLIOTCABLE. This is just a temporary version which I need to publish a dependent app, waiting for some pull request to be merged. Not meant to replace ELLIOTCABLE's bindings at all.

You can safely ignore the installation instructions below when compiling to JS. Instead:

  1. If you're writing an app or a similar end-consumer project, install BuckleScript compiler (a peerDependency of this project) via npm.

    $ npm install --save bs-platform

    Worh repeating: do not add this dependency to a library! The final application-developer should generally select the version of the BuckleScript compiler; you don't want users having duplicated versions of the compiler in their node_modules. Instead, library developers should add bs-platform to both "peerDependencies" (with a permissive version), and "devDependencies" (with a restrictive version):

    $ npm install --save-dev bs-platform
     "devDependencies": {
       ...
       "bs-platform": "^5.0.0"
     },
     "peerDependencies": {
    +  "bs-platform": "4.x || 5.x" // example. express the versions of BuckleScript you support here.
     },
  2. Install bs-cmdliner as a runtime-dependency.

    npm install --save @elliottcable/bs-cmdliner
  3. Manually add bs-cmdliner to your bsconfig.json's bs-dependencies:

    "bs-dependencies": [
      ...
      "@elliottcable/bs-cmdliner"
    ],
  4. Write a CLI!

The usage docs are below, but one thing worth noting, is that Node.js doesn't follow the POSIX standard for argv; so you need to prepend process.argv.shift() or similar to actually executing your command-line interface. Something like this should do:

(* OCaml syntax *)
open Cmdliner
[%%raw "process.argv.shift()"]

let hello () = print_endline "Hello, world!"
let hello_t = Term.(const hello $ const ())

let () = Term.exit @@ Term.eval (hello_t, Term.info "wrange")
/* ReasonML syntax */
open Cmdliner;
%raw "process.argv.shift()";

let hello = () => print_endline("Hello, world!");
let hello_t = Term.(const(hello) $ const());

let () = Term.exit @@ Term.eval((hello_t, Term.info("wrange")));

Versioning of this package

Thanks to SemVer not including a ‘generation’ number, there's really no way I can reasonably tie this project's version on npm to the upstream version of Cmdliner as released to opam by Daniel. As ugly as it is, I've opted to pin the major version of bs-cmdliner, to the flattened major and minor versions of the upstream project.

This means that the ported versions would look something like this:

| cmdliner (opam) | bs-cmdliner (npm) | | --------------- | ------------------- | | v1.0.2 | v10.2.x | | v1.0.4 | v10.4.x |

(I'm applying this scheme as of bs-cmdliner v10.2.1.)

Correspondingly, this project can't really strictly adhere to SemVer; I have no control over the major/minor components of bs-cmdliner's published versions, and thus must compress breaking changes to the npm port into the patch-component. /=

NOTE: OCaml doesn't often move fast; and I can't say I have much intention to follow the upstream development of Cmdliner with a microscope. As of right now, BuckleScript (4.02.3) is pretty far behind upstream OCaml (4.08.0); and while there's a beta-release of a slightly-less-vastly-outdated version of BuckleScript out there (specifically, 4.06.1), it hasn't reached maturity yet.

As upstream Cmdliner has dropped support for 4.02.3; and BuckleScript's 4.06.1 release hasn't reached stability yet, I'm opting to not publish newer versions of Cmdliner to npm yet — this includes, as of this writing, Cmdliner 1.0.3 and 1.0.4.

If this affects you, and you are on 4.06.1 already, feel free to reach out directly if you want me to bump the version on npm. No promises, though, if substantial changes to the source are necessary to make it compile. (There's a reason I didn't stomp on the npm package names outside my own scope! ;))

Original README follows:

Cmdliner — Declarative definition of command line interfaces for OCaml

%%VERSION%%

Cmdliner allows the declarative definition of command line interfaces for OCaml.

It provides a simple and compositional mechanism to convert command line arguments to OCaml values and pass them to your functions. The module automatically handles syntax errors, help messages and UNIX man page generation. It supports programs with single or multiple commands and respects most of the POSIX and GNU conventions.

Cmdliner has no dependencies and is distributed under the ISC license.

Home page: http://erratique.ch/software/cmdliner
Contact: Daniel Bünzli <daniel.buenzl [email protected]>

Installation

Cmdliner can be installed with opam:

opam install cmdliner

If you don't use opam consult the opam file for build instructions.

Documentation

The documentation and API reference is automatically generated by from the source interfaces. It can be consulted online or via odig doc cmdliner.

Sample programs

If you installed Cmdliner with opam sample programs are located in the directory opam config var cmdliner:doc. These programs define the command line of some classic programs.

In the distribution sample programs are located in the test directory of the distribution. They can be built and run with:

topkg build --tests true && topkg test