GithubHelp home page GithubHelp logo

leostera / bs-cmdliner Goto Github PK

View Code? Open in Web Editor NEW

This project forked from elliottcable/bs-cmdliner

0.0 2.0 0.0 409 KB

(BuckleScript package of) Declarative definition of command line interfaces for OCaml

Home Page: http://erratique.ch/software/cmdliner

License: ISC License

OCaml 99.20% Makefile 0.78% Standard ML 0.02%

bs-cmdliner's Introduction

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.)

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

  1. Install this fork through npm:

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

     "bs-dependencies": [
       ...
       "@elliottcable/bs-cmdliner"
     ],
    
  3. 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")));

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.07.0) anyway, so I'm fairly worried that future versions of Cmdliner won't compile on BuckleScript.

In any case, 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

bs-cmdliner's People

Contributors

dbuenzli avatar hhugo avatar elliottcable avatar avsm avatar emillon avatar leostera avatar rleonid avatar altgr avatar mstarzyk avatar raphael-proust avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.